Code Monkey home page Code Monkey logo

alt-tab-macos's Introduction

alt-tab-macos's People

Contributors

adamnemecek avatar afzalive avatar akx avatar ayroblu avatar calinou avatar damonpam avatar decodism avatar gcbw avatar gingerr avatar grzegorzkazana avatar hughlilly avatar i0ntempest avatar karbassi avatar l1cardo avatar lwouis avatar metacodes avatar mnin avatar mrpaschenko avatar nella17 avatar notlmn avatar phungtuanhoang1996 avatar rbnis avatar rjevski avatar ryenus avatar samdenty avatar semantic-release-bot avatar skolj avatar xanathar avatar xconverge avatar zacharee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alt-tab-macos's Issues

Add an app icon

This is OSS, so for the icon creation process, I don't want to decide everything. However, I would like to share some important considerations:

Asks:

  • I would like an editable file to be also provided in the PR (e.g. .psd, .svg, etc). The purpose is that the icon can evolve later
  • I would like the icon to avoid using text to avoid i18n issues
  • For the menubar, I think it is expected by user to have the choice between a monochrome or color icon. Also Dark Mode should be supported somehow. Not sure what's best practice here. The advantage of text here is that it was supporting everything out-of-the-box there

Discussion:

I looked at /System/Library/CoreServices/Dock.app, and I like the abstract icon:

image

Also the Mission Control icon (can't find where it is again today):

image

I think something similar may be a good idea: an abstract list of windows, and maybe some arrow showing a switch from one to another.

Also as inspiration, here is what similar apps have gone with:

Windows Switcher
image

HyperSwitch
image

Witch
image

Context
image

Windows sometimes are not listed

Opening this window in chrome:
https://www.youtube.com/watch?v=EQwOKQKv4Pg

It seems the title of the window doesn't match between the 2 OS APIs:

  • AXUIElementCopyAttributeValue: "final fantasy ⁷ ~ lofi hip hop mix - YouTube - Audio playing - Google Chrome - Home"
  • CGWindowListCopyWindowInfo: "final fantasy ⁷ ~ lofi hip hop mix - YouTube 🔊"

We could implement a workaround specific to youtube. It would be nicer of course to find a general approach.

Display windows from other Spaces

Currently windows from other spaces, including fullscreen'd windows that are in their own space, are not displayed in the thumbnails

Does not work when opened from .app

Switching works fine when I open it from terminal /Applications/alt-tab-macos.app/Contents/MacOS/alt-tab-macos but it doesn't show the switching popup when I open the app from Finder or open /Applications/alt-tab-macos.app/
It runs in status bar and binds to ctlr + tab shortcut because I can not longer switch between Firefox tabs but nothing happens. I have given the app Accessibility permission.
Tested on latest macOS Catalina version.

version numbers damaged

i've downloaded version 1.4.5 but when selecting it in the Finder it claims to be version 1.0

Screenshot 2019-10-21 at 14 14 28

the CFBundleVersion and CFBundleShortVersionString entries in your Info.plist file are incorrect

Error loading preferences from JSON file on disk

Error

When installing the latest version on my workstation, the app does not start.

By CLI, it seems to be an issue with the config file parsing.

"Error loading preferences from JSON file on disk" "Optional contained nil"

Data

➜  ~ cat ~/Library/Preferences/alt-tab-macos.json
{
  "windowDisplayDelay" : "200",
  "cellPadding" : "6",
  "thumbnailMaxHeight" : "0",
  "metaModifierFlag" : "262144",
  "maxScreenUsage" : "0.8",
  "cellBorderWidth" : "2",
  "thumbnailMaxWidth" : "0",
  "highlightColor" : "white",
  "maxThumbnailsPerRow" : "4",
  "fontHeight" : "15",
  "thumbnailQuality" : "4",
  "interItemPadding" : "4",
  "metaKey" : "59",
  "tabKey" : "48",
  "iconSize" : "32",
  "windowPadding" : "20"
}%
➜  ~ cat ~/Library/Preferences/alt-tab-macos-defaults.json
{
  "windowDisplayDelay" : "200",
  "cellPadding" : "6",
  "thumbnailMaxHeight" : "0",
  "metaModifierFlag" : "262144",
  "maxScreenUsage" : "0.8",
  "cellBorderWidth" : "2",
  "thumbnailMaxWidth" : "0",
  "highlightColor" : "white",
  "maxThumbnailsPerRow" : "4",
  "fontHeight" : "15",
  "thumbnailQuality" : "4",
  "interItemPadding" : "4",
  "metaKey" : "59",
  "tabKey" : "48",
  "iconSize" : "32",
  "windowPadding" : "20"
}%

Info

➜  ~ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14.6
BuildVersion:	18G103
25 › <key>CFBundleVersion</key>
 26 › <string>1.5.1</string>

Allow user to see the version used

When filing bug reports, it's useful to be able to send the version of the software that the user is running. Currently, as far as I can tell, there's no way to see this. When there's a config panel (#8) it could be shown there. It would also be a good idea to put the version in the downloaded archive name.

Thumbnails are ordered by z-axis, not recently-used-first

If you switch to an app via the dock icon, all windows of that app become ‘recently used’ in the alt-tab menu.

The documentation for the kCGWindowListOptionOnScreenOnly constant says:

List all windows that are currently onscreen. Windows are returned in order from front to back. When retrieving a list with this option, the relativeToWindow parameter should be set to kCGNullWindowID.

Original author on this HackerNews thread

Handle minimized windows

It is not possible to display thumbnails for minimized windows, but we could display a message instead.

Listing the minimized windows would be done by removing .optionOnScreenOnly in CGWindowListCopyWindowInfo([.excludeDesktopElements], kCGNullWindowID)

Allow arrow keys

Allow arrow keys to move backward and forward between open windows when switcher is active. Right now, the only way to move backward is to shift tab, or to select previous window with mouse.

Add quick-actions on thumbnails

Add quick actions on thumbnails, similar to what WindowSwitcher is doing:

image

I think only these are actually useful:

  • Resize half-screen left/right/up/down
  • Resize full-screen
  • Quit

In a first phase, keyboard only, then maybe some visual buttons can be added.

More details in this video, especially the minimize behaviour which shows limitation of the Mac API (can't get thumbnail of a minimized window)

Sign .app to avoid the "app from an unidentified developer" prompt

The .app is unsigned currently. When the user opens the app for the first time, they get a scary prompt, and must jump through hoops to allow the app to run:

image

Getting an apple certificate and signing the app would remove that friction.

Here is a tutorial: https://successfulsoftware.net/2012/08/30/how-to-sign-your-mac-os-x-app-for-gatekeeper/

An issue is that this means buying a 100$/year apple dev account. Beyond the money, it makes this less of an open-source project as i would need my personal paid account to sign. Forks would need their own accounts to sign. I don't think there is any way around this though. This is an Apple ecosystem limitation.

Mac App Store

Any chance this could be distributed on the Mac App Store as well?

Second screen menu bar disappears

After installing alt-tab (now I've uninstalled it, didnt help) my menu now is disappearing. I have a second monitor hooked up and when I use/open something in the second screen, my menu bar on my mac goes white (https://imgur.com/a/eZpGknW), what has happend, would like to fix this asap

App stops reacting to shortcuts sometimes

During normal usage, sometimes the app will stop responding to global shortcuts.

I recorded an instance of this where I saw these logs:

"event" 11
"event" 12
"meta down"
"unexpected 1" [2807: 1]
"unexpected 2" [<AXUIElement 0x7ff860f95c40> {pid=2807}]
"event" 12
"meta up"
"event" 12
"event" 12
"event" 11
"event" 12
"meta down"
"unexpected 1" [2807: 1, 13366: 0]
"unexpected 2" [<AXUIElement 0x7ff860f8e3b0> {pid=2807}]
"event" 10
"event" 4294967294

These logs come from this update I made locally in the source code:

func computeOpenWindows() {
        openWindows.removeAll()
        // we rely on the fact that CG and AX APIs arrays follow the same order to match objects from both APIs
        var pidAndCurrentIndex: [pid_t: Int] = [:]
        for cgWindow in cgWindows() {
            let cgId = cgWindow[kCGWindowNumber] as! CGWindowID
            let cgTitle = String(cgWindow[kCGWindowName] as! NSString)
            let cgOwnerPid = cgWindow[kCGWindowOwnerPID] as! pid_t
            let i = pidAndCurrentIndex.index(forKey: cgOwnerPid)
            pidAndCurrentIndex[cgOwnerPid] = (i == nil ? 0 : pidAndCurrentIndex[i!].value + 1)
            let axWindow = axWindows(cgOwnerPid)
            if axWindow.count > pidAndCurrentIndex[cgOwnerPid]! {
                openWindows.append(OpenWindow(target: axWindow[pidAndCurrentIndex[cgOwnerPid]!], ownerPid: cgOwnerPid, cgId: cgId, cgTitle: cgTitle))
            } else {
                debugPrint("unexpected 1", pidAndCurrentIndex)
                debugPrint("unexpected 2", axWindow)
            }
        }
    }

Note that the app isn't crashed. It is ignoring global shortcuts and stdout isn't producing new values

Recomputing Thumbnails is slow and expensive

First of all, thank you for this great app, I really like it!

However, on my 2016 MacBook Pro, getting the UI to show up feels very sluggish, even though I set the delay to 0ms. After investigating the code a bit and running some tests, it seems like recomputing the thumbnails every time the UI shows up is quite expensive.

In my testing I had around 10 windows open and the following lines of code resulted in around 200ms of time:

collectionView_!.setFrameSize(maxSize)
collectionView_!.collectionViewLayout!.invalidateLayout()
collectionView_!.reloadData()
collectionView_!.layoutSubtreeIfNeeded()

Most of that time was spent in the thumbnail function of OpenWindow. A few suggestions on how this could be fixed:

  • Use multithreading for capturing the thumbnails.
  • Capture thumbnails on background thread, then when done update the UI. This would really help getting the UI to show instantly. However, to be able to show something for each window initially I would also:
  • Cache the previously captured thumbnails.
  • Figure out how Mission Control does it and replicate that. If it's similar to iOS multitasking, it's probably taking spontaneous snapshots and storing them somewhere on disk. If we could figure out where, then those could be used.
  • Have a continuously running background task that captures thumbnails every few seconds / minutes and caches them. (Maybe even checks if anything changed and if not increase the time for that specific window?)

Some windows don't show in the list

Some apps (like Slack) seem to handle window titles differently.

In WindowManager.swift's axWindows function, windows get filtered by whether they have a title or not. Slack for example does have a title (passes the check in Application.swift's computeOpenWindows) but it returns nil here. My guess is we should remove the title validation in axWindows.

Show app version in the menubar menu

It is helpful to identify which version of the app one is running. This can be done by simply adding a new text line in the menubar menu.

Version is generated during CI build on master. I bash script could replace some placeholder in the code before the xcodebuild happens.

Donation button

I really like that you made this available to the proprietary abandonware (but otherwise mostly working) Hyperswitch. Could you provide a way to allow users to make a donation?

Incorrect switcher sizing with vertical monitor layout

I use two monitors side by side in a vertical layout. The switcher overlay extends past the borders of one of the windows, making some of the windows hard to identify (and looking ugly).

IMG_7096 (1)

I'm using Mojave 10.14.6. I can't find a way to get a version for AltTab but I just downloaded it.

Let users set some preferences

Let users customize some defaults values. In order of usefulness:

  • Keys used in the global shortcuts
  • Max sizes of thumbnails
  • Debounce delay before the thumbnails appear
  • Other: sizes, paddings, colors, fonts, thumbnails quality, basically all constants at the top of Application.swift

To illustrate, this is how HyperSwitch does it:

image

Close on Esc

Not sure, how it is now in Windows 10, but my fingers remember that when looping through windows hitting Esc cancels it, which is pretty useful when you've changed you mind or satisfied with a window preview. Of course Ctr-Shift-Tab is an option to go back but not that useful.

Allow changing keybinds :enhancement:

Could you allow a way to modify https://github.com/lwouis/alt-tab-macos/blob/master/alt-tab-macos/resources/preferences.json within a text editor, say in ~/Application Support/Library/AltTab/preferences.json? That would the user to change the keybind.

In Hyperdock (combined with Karabiner Elements / Hammerspoon) I use Cmd+Space to "alt tab" and Meta+Cmd+Space to "alt tab within application". It allows to keep Ctrl+Tab intact, as it is also used in e.g. Firefox, iTerm, ...

In this example, I would like to change

"metaKey": 59,

to

"metaKey": 55,

as per [1]

[1] https://eastmanreference.com/complete-list-of-applescript-key-codes

Focusing the wrong window with multiple displays

If i have two displays setup like like
DIsplay 1: Chrome1
Display 2: Spotify Chrome2

If i control-tab from Spotify to Chrome1 then Chrome2 is focussed instead. It doesn't happen if I swap Chrome1 and Chrome2 so I have a feeling it depends on the order of the two windows being opened

Update the thumbnails live when windows get closed or new windows are opened

Right now the UI shows a snapshot of windows at the time the shortcut is pressed. This has pros: the UI is stable and not changing on the user, but also cons: the UI doesn't reflect the current state of windows.

It's a tradeoff between stability and change. I would love feedback from other people about this. Making it should be a preference?

App crashes sometimes

App crashed with following log in AppCode:

"event" 12
"event" 12
"meta down"
"event" 10
"meta+tab down"
"event" 11
"event" 12
"meta up"
Fatal error: Unexpectedly found nil while unwrapping an Optional value
"event" 12
"meta down"

Process finished with exit code 132 (interrupted by signal 4: SIGILL)

Better UX to set user preferences

Current UI to set user preferences is raw:

image

Goal 1

Fewer options and better validation. In order of priority:

  • tab key -> dropdown or "press the key" button
  • meta key + meta key modifier -> dropdown or "press the key" button
  • thumbnail quality -> dropdown
  • maximum size of main window -> clarify unit; maybe switch to a slider
  • padding in the main window -> clarify unit; maybe switch to a slider
  • padding in each cell -> clarify unit; maybe switch to a slider
  • border width of each cell -> clarify unit; maybe switch to a slider
  • max number of thumbnails -> maybe switch to a slider
  • maximum width of thumbnails -> clarify unit; maybe switch to a slider
  • maximum height of thumbnails -> clarify unit; maybe switch to a slider
  • app icon size -> clarify unit; maybe switch to a slider
  • font height -> clarify unit; maybe switch to a slider
  • padding between cells -> clarify unit; maybe switch to a slider
  • delay in ms -> clarify unit; maybe switch to a slider

Here is HyperSwitch more refined UI as reference:

image

Goal 2

Better documentation. Replace current text with shorter explanations, and add either a hover tooltip or some other variation of more-info-on-demand UI, so that users who found the short text unclear can get more explanations. We can think about adding illustrations/images/videos here too to help get the point across.

Goal 3

Make categories like dimensions, keyboard, performance, etc. This can be tabs as is traditional on macOS, or any other approach.

Goal 4

Make all preferences live. Currently some of them are live, and some require a restart to apply. An easy fix would be to kill and recreate the main window on preferences change. Another brute-force approach would be to add a "restart the app" button at the bottom.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.