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

Detection of menubar visibility (and/or) dimensions do not work on Apple Silicon M1 (arm64) #793

Closed
koekeishiya opened this issue Jan 14, 2021 · 9 comments
Labels
Apple Silicon Only related to Apple Silicon machines bug Something isn't working

Comments

@koekeishiya
Copy link
Owner

The code responsible for this works fine on macOS Big Sur running on intel architecture.

Responsible functions:

check if menubar is visible:
https://github.com/koekeishiya/yabai/blob/master/src/display_manager.c#L200

retrieve dimensions of menubar:
https://github.com/koekeishiya/yabai/blob/master/src/display_manager.c#L207

Help welcome if someone with an M1 wants to debug the result of these functions to see what they output.

@koekeishiya koekeishiya added the bug Something isn't working label Jan 14, 2021
@koekeishiya koekeishiya added the Apple Silicon Only related to Apple Silicon machines label Jan 14, 2021
@alin23
Copy link

alin23 commented Jan 24, 2021

Looks like SLSGetRevealedMenuBarBounds doesn't populate the CGRect anymore:

SLSMainConnectionID: 859503
SLSGetMenuBarAutohideEnabled: 0
SLSGetActiveSpace: 7
SLSManagedDisplayGetCurrentSpace: 7
2021-01-24 16:00:44.590 test[71825:1662024] SLSGetRevealedMenuBarBounds: {
    Height = 0;
    Width = 0;
    X = 0;
    Y = 0;
}

This is the code used:

    int g_connection = SLSMainConnectionID();
    printf("SLSMainConnectionID: %d\n", g_connection);

    int status = 0;
    SLSGetMenuBarAutohideEnabled(g_connection, &status);
    printf("SLSGetMenuBarAutohideEnabled: %d\n", status);

    int activeSpace = SLSGetActiveSpace(g_connection);
    printf("SLSGetActiveSpace: %d\n", activeSpace);

    activeSpace = SLSManagedDisplayGetCurrentSpace(g_connection, CFUUIDCreateString(NULL, CGDisplayCreateUUIDFromDisplayID(CGMainDisplayID())));
    printf("SLSManagedDisplayGetCurrentSpace: %d\n", activeSpace);

    CGRect bounds = {};
    SLSGetRevealedMenuBarBounds(&bounds, g_connection, activeSpace);
    NSLog(@"SLSGetRevealedMenuBarBounds: %@\n", CGRectCreateDictionaryRepresentation(bounds));

@koekeishiya
Copy link
Owner Author

koekeishiya commented Jan 24, 2021 via email

@alin23
Copy link

alin23 commented Jan 24, 2021

Interesting, that seems to work fine:

❯ file test.x64                                                  
test.x64: Mach-O 64-bit executable x86_64

❯ ./test.x64                                                     
SLSMainConnectionID: 483075
SLSGetMenuBarAutohideEnabled: 0
SLSGetActiveSpace: 7
SLSManagedDisplayGetCurrentSpace: 5
2021-01-24 18:55:57.380 test.x64[88089:2187176] SLSGetRevealedMenuBarBounds: {
    Height = 24;
    Width = 1680;
    X = 0;
    Y = 0;
}

❯ ./test                                                         
SLSMainConnectionID: 483283
SLSGetMenuBarAutohideEnabled: 0
SLSGetActiveSpace: 7
SLSManagedDisplayGetCurrentSpace: 5
2021-01-24 18:56:10.114 test[88209:2188451] SLSGetRevealedMenuBarBounds: {
    Height = 0;
    Width = 0;
    X = 0;
    Y = 0;
}

@alin23
Copy link

alin23 commented Jan 24, 2021

Looks like a bug in SkyLight. Until Apple fixes this, we can work around it using:

yabai -m config top_padding x + 24
Where x is our actual wanted top padding.

@koekeishiya koekeishiya added the addressed on master; not released Fixed upstream, but not yet released label Feb 14, 2021
@koekeishiya koekeishiya added the-future I never think of the future - it comes soon enough. and removed addressed on master; not released Fixed upstream, but not yet released labels May 6, 2021
@es183923
Copy link

This may break with the new MacBook Pro's, as their menu bar seems to be quite a bit taller.

@koekeishiya
Copy link
Owner Author

This is guaranteed to break on the new MacBook Pro's, as we need to deal with the Notch in some way or another. Hopefully there is some API that we can use here.

@koekeishiya
Copy link
Owner Author

Well this is just great; the height of the menubar changes based on the selected resolution this time around, so I guess we have to dig for a new kind of API. In default resolution the lowest y-coordinate usable on a display with notch is 38, where as with the 14" maximum scaled resolution it changes to 44.

@koekeishiya
Copy link
Owner Author

Fixed on master using the same technique as to detect that a notch is present. For non-notch Apple Silicon MacBooks we just assume that the menubar height is 24em as I have no way to experiment with such a build.

@koekeishiya
Copy link
Owner Author

koekeishiya commented Jan 17, 2022

Note to self.

The following function is able to properly grab the display height on both x86_64 and arm64 running Monterey:
extern CGError SLSGetDisplayMenubarHeight(uint32_t did, uint32_t *height);
This function will return the height regardless of whether the menubar is hidden or not.

@koekeishiya koekeishiya removed addressed on master; not released Fixed upstream, but not yet released the-future I never think of the future - it comes soon enough. labels Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apple Silicon Only related to Apple Silicon machines bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants