MacosUtil .java

com.mojang.blaze3d.platform.MacosUtil (class): members: setCtrlClickEmulatesRightClick, setFullscreenMenuVisibility, disableCloseWindowMenuItem, IS_MACOS.

com.mojang.blaze3d.platformclass53 linesclient1.7 KB

API Surface (3)

void disableCloseWindowMenuItem()
void setFullscreenMenuVisibility(final boolean value)
void setCtrlClickEmulatesRightClick(final boolean value)

Fields & Constants (1)

IS_MACOS

String literals (13)

"NSApplication"
"sharedApplication"
"windowsMenu"
"numberOfItems"
"itemAtIndex:"
"action"
"setEnabled:"
"setHidden:"
"setKeyEquivalent:"
"SDL_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY"
"SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK"
"performClose:"
"closeAll:"

Code Graph: Dependencies (1)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

MacosUtil.java53 lines · Minecraft 26.3 · verbatim
1
package com.mojang.blaze3d.platform;
2
3
import ca.weblite.objc.Client;
4
import ca.weblite.objc.Proxy;
5
import java.util.Set;
6
import net.fabricmc.api.EnvType;
7
import net.fabricmc.api.Environment;
8
import net.minecraft.util.Util;
9
import net.minecraft.util.Util.OS;
10
import org.lwjgl.sdl.SDLHints;
11
import org.lwjgl.system.macosx.ObjCRuntime;
12
13
@Environment(EnvType.CLIENT)
14
public final class MacosUtil {
15
	public static final boolean IS_MACOS = Util.getPlatform() == OS.OSX;
16
17
	private MacosUtil() {
18
	}
19
20
	public static void disableCloseWindowMenuItem() {
21
		if (IS_MACOS) {
22
			Proxy windowsMenu = Client.getInstance().sendProxy("NSApplication", "sharedApplication", new Object[0]).sendProxy("windowsMenu", new Object[0]);
23
			int itemCount = windowsMenu.sendInt("numberOfItems", new Object[0]);
24
25
			for (int i = 0; i < itemCount; i++) {
26
				Proxy item = windowsMenu.sendProxy("itemAtIndex:", new Object[]{i});
27
				if (MacosUtil.DisabledActions.SELECTORS.contains((Long)item.sendRaw("action", new Object[0]))) {
28
					item.send("setEnabled:", new Object[]{false});
29
					item.send("setHidden:", new Object[]{true});
30
					item.send("setKeyEquivalent:", new Object[]{""});
31
				}
32
			}
33
		}
34
	}
35
36
	public static void setFullscreenMenuVisibility(final boolean value) {
37
		if (IS_MACOS) {
38
			SDLHints.SDL_SetHint("SDL_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY", value ? "1" : "0");
39
		}
40
	}
41
42
	public static void setCtrlClickEmulatesRightClick(final boolean value) {
43
		if (IS_MACOS) {
44
			SDLHints.SDL_SetHint("SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK", value ? "1" : "0");
45
		}
46
	}
47
48
	@Environment(EnvType.CLIENT)
49
	private static final class DisabledActions {
50
		private static final Set<Long> SELECTORS = Set.of(ObjCRuntime.sel_getUid("performClose:"), ObjCRuntime.sel_getUid("closeAll:"));
51
	}
52
}
53

Decompiled Minecraft 26.3 source of MacosUtil (com/mojang/blaze3d/platform/MacosUtil.java) with Mojang official mappings, stored verbatim on the site.