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

zathura not being managed, yabai 7.0.2 #2168

Closed
hershkumar opened this issue Mar 15, 2024 · 11 comments
Closed

zathura not being managed, yabai 7.0.2 #2168

hershkumar opened this issue Mar 15, 2024 · 11 comments
Labels
external Code outside our control

Comments

@hershkumar
Copy link

After upgrading to yabai 7.0.2, zathura is no longer being managed by yabai.

The output of yabai -m query --windows produces:

"id":1969,
	"pid":23107,
	"app":"zathura",
	"title":"/Users/hersh/Documents/School/work/latex/physics/phys613/notes/compiled.pdf",
	"frame":{
		"x":0.0000,
		"y":38.0000,
		"w":800.0000,
		"h":628.0000
	},
	"role":"",
	"subrole":"",
	"root-window":true,
	"display":1,
	"space":4,
	"level":0,
	"sub-level":0,
	"layer":"normal",
	"sub-layer":"normal",
	"opacity":1.0000,
	"split-type":"none",
	"split-child":"none",
	"stack-index":0,
	"can-move":false,
	"can-resize":false,
	"has-focus":false,
	"has-shadow":true,
	"has-parent-zoom":false,
	"has-fullscreen-zoom":false,
	"has-ax-reference":false,
	"is-native-fullscreen":false,
	"is-visible":false,
	"is-minimized":false,
	"is-hidden":false,
	"is-floating":false,
	"is-sticky":false,
	"is-grabbed":false

with no role being given to the window. Restarting yabai, the computer, or zathura, does not seem to make any difference to whether zathura is managed.

@koekeishiya
Copy link
Owner

Note:

"has-ax-reference":false,

https://github.com/koekeishiya/yabai/blob/master/doc/yabai.asciidoc#query

Some window properties are only accessible when yabai has a valid AX-reference for that window.
This AX-reference can only be retrieved when the space that the window is visible on, is active.
If windows are already opened on inactive spaces when yabai is launched, yabai can detect those
windows and retrieve a limited amount of information about them. In addition, yabai window commands
will NOT WORK for these windows. These windows can be identified by looking at the has-ax-reference
property. Once the space that the window belongs to becomes active, yabai will automatically create
an AX-reference. The queries will from that point forwards contain complete information, and the window
can be used with yabai window commands.

#2164

@koekeishiya
Copy link
Owner

koekeishiya commented Mar 16, 2024

Maybe #2118 but that is is just absolutely ridiculous from Zathura at that point and you should report a bug there.

if (process_info.processMode & modeOnlyBackground) {
debug("%s: background-only service '%s' detected! ignoring..\n", FUNCTION, process_name);
return NULL;
}

Run yabai --stop-service and run yabai from the terminal: yabai --verbose and see if you see that debug-print for zathura.

@naba-nyan
Copy link

Hi, koekeishiya.
Last day, I asked the issue at #2164.
This is my debug log with the following minimal yabairc.

CPU: Apple M1
OS: Sonoma 14.3.1

As shown in the log, zathura is detected by yabai but ignored...

P.S. By downgrading, it works fine with v.6.0.15,
but does not work fine with v.7.0.0.

#!/usr/bin/env bash
# vim: fenc=utf-8 et ts=2 sw=2 sts=0
# vim: fdm=marker fdl=1

# the scripting-addition must be loaded manually if
# you are running yabai on macOS Big Sur. Uncomment
# the following line to have the injection performed
# when the config is executed during startup.
#
# for this to work you must configure sudo such that
# it will be able to run the command without password
#
# see this wiki page for information:
#  - https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)#configure-scripting-addition

# script addition: {{{1
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa

# global settings: {{{1
yabai -m config external_bar                all:32:0
#yabai -m config menubar_opacity            [<BOOL_SEL>]
yabai -m config mouse_follows_focus         on
yabai -m config focus_follows_mouse         autofocus
yabai -m config display_arrangement_order   default
yabai -m config window_origin_display       default
yabai -m config window_placement            second_child
#yabai -m config window_zoom_persist        [<BOOL_SEL>]
yabai -m config window_shadow               off
yabai -m config window_opacity              off
yabai -m config window_opacity_duration     0.0
yabai -m config active_window_opacity       1.0
yabai -m config normal_window_opacity       0.8
yabai -m config insert_feedback_color       0xffd75f5f
yabai -m config split_ratio                 0.6
yabai -m config split_type                  vertical
yabai -m config auto_balance                on
yabai -m config mouse_modifier              alt
yabai -m config mouse_action1               move
yabai -m config mouse_action2               resize
yabai -m config mouse_drop_action           swap

# general space settings:
yabai -m config layout                      bsp
yabai -m config top_padding                 10
yabai -m config bottom_padding              10
yabai -m config left_padding                10
yabai -m config right_padding               10
yabai -m config window_gap                  5
process_create: background-only service 'loginwindow' detected! ignoring..
process_create: background-only service 'WindowManager' detected! ignoring..
process_create: background-only service 'SystemUIServer' detected! ignoring..
process_create: background-only service 'コントロールセンター' detected! ignoring..
process_create: background-only service '壁紙' detected! ignoring..
process_create: xpc service 'ViewBridgeAuxiliary' detected! ignoring..
process_manager_add_running_processes: Finder (613) was found! caching psn..
process_create: background-only service 'Wi-Fi' detected! ignoring..
process_create: background-only service '通知センター' detected! ignoring..
process_create: background-only service 'UIKitSystem' detected! ignoring..
process_create: background-only service 'Spotlight' detected! ignoring..
process_create: background-only service 'GoogleJapaneseInput' detected! ignoring..
process_create: background-only service 'GoogleJapaneseInputRenderer' detected! ignoring..
process_create: xpc service 'CursorUIViewService' detected! ignoring..
process_create: background-only service 'TextInputMenuAgent' detected! ignoring..
process_create: background-only service 'AirPlayUIAgent' detected! ignoring..
process_create: background-only service 'AdGuard for Safari' detected! ignoring..
process_create: background-only service 'AltTab' detected! ignoring..
process_create: background-only service 'PowerChime' detected! ignoring..
process_create: background-only service 'chronod' detected! ignoring..
process_create: background-only service 'CoreServicesUIAgent' detected! ignoring..
process_create: background-only service 'ユニバーサルコントロール' detected! ignoring..
process_create: background-only service 'Keychain Circle Notification' detected! ignoring..
process_create: background-only service 'CoreLocationAgent' detected! ignoring..
process_create: background-only service 'TextInputSwitcher' detected! ignoring..
process_create: background-only service 'OSDUIHelper' detected! ignoring..
process_create: background-only service 'universalAccessAuthWarn' detected! ignoring..
process_create: background-only service 'ファミリー' detected! ignoring..
process_create: background-only service 'studentd' detected! ignoring..
process_create: background-only service 'coreautha' detected! ignoring..
process_create: xpc service 'CalendarWidgetExtension' detected! ignoring..
process_create: background-only service 'skhd' detected! ignoring..
process_create: background-only service 'Dock' detected! ignoring..
process_create: xpc service 'Dockエクストラ' detected! ignoring..
process_create: background-only service 'sketchybar' detected! ignoring..
process_create: background-only service 'BackgroundTaskManagementAgent' detected! ignoring..
process_create: xpc service 'QuickLookSatellite' detected! ignoring..
process_create: background-only service 'printtool' detected! ignoring..
process_create: background-only service 'yabai' detected! ignoring..
window_manager_create_and_add_window:1488 iTerm2 - Default (yabai) (AXWindow:AXStandardWindow:1)
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 1488
EVENT_HANDLER_DAEMON_MESSAGE: signal --add event=dock_did_restart action=sudo yabai --load-sa
EVENT_HANDLER_DAEMON_MESSAGE: config external_bar all:32:0
EVENT_HANDLER_DAEMON_MESSAGE: config mouse_follows_focus on
EVENT_HANDLER_DAEMON_MESSAGE: config focus_follows_mouse autofocus
EVENT_HANDLER_DAEMON_MESSAGE: config display_arrangement_order default
EVENT_HANDLER_DAEMON_MESSAGE: config window_origin_display default
EVENT_HANDLER_DAEMON_MESSAGE: config window_placement second_child
EVENT_HANDLER_DAEMON_MESSAGE: config window_shadow off
EVENT_HANDLER_DAEMON_MESSAGE: config window_opacity off
EVENT_HANDLER_DAEMON_MESSAGE: config window_opacity_duration 0.0
EVENT_HANDLER_DAEMON_MESSAGE: config active_window_opacity 1.0
EVENT_HANDLER_DAEMON_MESSAGE: config normal_window_opacity 0.8
EVENT_HANDLER_DAEMON_MESSAGE: config insert_feedback_color 0xffd75f5f
EVENT_HANDLER_DAEMON_MESSAGE: config split_ratio 0.6
EVENT_HANDLER_DAEMON_MESSAGE: config split_type vertical
EVENT_HANDLER_DAEMON_MESSAGE: config auto_balance on
EVENT_HANDLER_DAEMON_MESSAGE: config mouse_modifier alt
EVENT_HANDLER_DAEMON_MESSAGE: config mouse_action1 move
EVENT_HANDLER_DAEMON_MESSAGE: config mouse_action2 resize
EVENT_HANDLER_DAEMON_MESSAGE: config mouse_drop_action swap
EVENT_HANDLER_DAEMON_MESSAGE: config layout bsp
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 1488
EVENT_HANDLER_WINDOW_RESIZED: iTerm2 1488
EVENT_HANDLER_WINDOW_MOVED:DEBOUNCED iTerm2 1488
EVENT_HANDLER_WINDOW_RESIZED:DEBOUNCED iTerm2 1488
EVENT_HANDLER_DAEMON_MESSAGE: config top_padding 10
EVENT_HANDLER_WINDOW_RESIZED: iTerm2 1488
EVENT_HANDLER_WINDOW_MOVED:DEBOUNCED iTerm2 1488
EVENT_HANDLER_DAEMON_MESSAGE: config bottom_padding 10
EVENT_HANDLER_WINDOW_RESIZED: iTerm2 1488
EVENT_HANDLER_DAEMON_MESSAGE: config left_padding 10
EVENT_HANDLER_WINDOW_RESIZED: iTerm2 1488
EVENT_HANDLER_WINDOW_MOVED:DEBOUNCED iTerm2 1488
EVENT_HANDLER_DAEMON_MESSAGE: config right_padding 10
EVENT_HANDLER_WINDOW_RESIZED: iTerm2 1488
EVENT_HANDLER_DAEMON_MESSAGE: config window_gap 5
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 1488
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 1488
window_manager_create_and_add_window:1593 iTerm2 -  (AXWindow:AXStandardWindow:1)
EVENT_HANDLER_WINDOW_FOCUSED: iTerm2 1593
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 1488
EVENT_HANDLER_WINDOW_RESIZED: iTerm2 1488
EVENT_HANDLER_WINDOW_RESIZED: iTerm2 1593
EVENT_HANDLER_WINDOW_MOVED:DEBOUNCED iTerm2 1593
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 1593
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 1593
process_create: background-only service 'zathura' detected! ignoring..
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 1593
EVENT_HANDLER_WINDOW_TITLE_CHANGED: iTerm2 1488
EVENT_HANDLER_APPLICATION_FRONT_SWITCHED: iTerm2 (589)
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window

@koekeishiya
Copy link
Owner

I have whitelisted zathura on master, but please report it in their bug-tracker. The issue is that zathura incorrectly identifies as a background-only process.

@koekeishiya koekeishiya added addressed not released Fixed upstream, but not yet released external Code outside our control labels Mar 16, 2024
@naba-nyan
Copy link

Thank you for addressing this problem.
I will report this phenomena to the zathura maintainer.
I am sure that it is a bug in zathura...

@sebastinas
Copy link

zathura is doing nothing on purpose to mark itself as background-only process (unless a user explicitly specifies -f to fork into the background). How does yahabi decide whether a process is a background process?

@koekeishiya
Copy link
Owner

koekeishiya commented Mar 18, 2024

The part which fails currently is information retrieved from GetProcessInformation(ProcessSerialNumber *psn, ProcessInfoRec *record)

The GetProcessInformation function returns information in a process information
record, which is defined by the ProcessInfoRec data type.

TYPE ProcessInfoRec =
RECORD
processInfoLength: LongInt; {length of process info record}
processName: StringPtr; {name of this process}
processNumber: ProcessSerialNumber;
{psn of this process}
processType: LongInt; {file type of application file}
processSignature: OSType; {signature of application file}
processMode: LongInt; {'SIZE' resource flags}
processLocation: Ptr; {address of partition}
processSize: LongInt; {partition size}
processFreeMem: LongInt; {free bytes in heap}
processLauncher: ProcessSerialNumber;
{process that launched this one}
processLaunchDate: LongInt; {time when launched}
processActiveTime: LongInt; {accumulated CPU time}
processAppSpec: FSSpecPtr; {location of the file}
END;

The specific field which yabai uses is processMode, and it checks the modeOnlyBackground bit.

processMode Process mode flags. These flags indicate whether the process is an
application or desk accessory. For applications, this field also
returns information specified in the application’s 'SIZE' resource.
This information is returned as flags. You can refer to these flags by
using these constants:

modeDeskAccessory = $00020000;
modeMultiLaunch = $00010000;
modeNeedSuspendResume = $00004000;
modeCanBackground = $00001000;
modeDoesActivateOnFGSwitch = $00000800;
modeOnlyBackground = $00000400;
modeGetFrontClicks = $00000200;
modeGetAppDiedMsg = $00000100;
mode32BitCompatible = $00000080;
modeHighLevelEventAware = $00000040;
modeLocalAndRemoteHLEvents = $00000020;
modeStationeryAware = $00000010;
modeUseTextEditServices = $00000008;

I know this function is marked as deprecated, but the ProcessInfoRec is very much alive in the WindowServer in modern macOS (including the latest release, Sonoma) and this flag is accurate for pretty much all software I personally have encountered. Even when launching software "backgrounded" (for example mpv) through a series of forks-exec, and as a background-job.

I have whitelisted zathura for yabai and I understand if you have other priorities and don't want to deal with this garbage, especially if you don't use macOS yourself.

Edit: Usually these settings are configured in the applications .plist file. If you distribute a single-binary instead of an application bundle, this plist information can be embedded into the binary during compilation/linkage.
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html

The preferences that seem relevant would be LSBackgroundOnly and LSUIElement

Edit: The reason for using this older API is that there is no actual modern replacement that captures the equivalent of this value for all processes (the modern solutions that I know of all rely on NSRunningApplication API which itself doesn't actually list/work for all processes we might be interested in).

@sebastinas
Copy link

Ah, I wasn't aware that this is a tool for macOS. In zathura we are relying on macOS users to help with patches. I have no way to test any changes on macOS.

@koekeishiya koekeishiya removed the addressed not released Fixed upstream, but not yet released label Mar 22, 2024
@mizlan
Copy link

mizlan commented Mar 23, 2024

I know this function is marked as deprecated

Interesting. Once this function is gone, is there a replacement, or a workaround?

@koekeishiya
Copy link
Owner

koekeishiya commented Mar 24, 2024

I wouldn't worry until it is actually removed. The concept is still very alive and maintained in todays WindowServer, so even if the public functions are removed, the structure is still there in the WindowServer and there are ways to get access to that information without much trouble.

@koekeishiya
Copy link
Owner

Changed how this works. Explicit whitelisting should no longer be necessary.

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

No branches or pull requests

5 participants