Skip to content

Commit

Permalink
osxutil: update frame extended state for fullscreen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-a authored and Adam- committed Jun 21, 2023
1 parent 8a0e1b0 commit 1030e14
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
package net.runelite.client.util;

import com.apple.eawt.Application;
import com.apple.eawt.FullScreenAdapter;
import com.apple.eawt.FullScreenUtilities;
import javax.swing.JFrame;
import com.apple.eawt.event.FullScreenEvent;
import lombok.extern.slf4j.Slf4j;

/**
Expand All @@ -36,14 +38,30 @@
public class OSXUtil
{
/**
* Enables the osx native fullscreen if running on a mac.
* Enables the osx native fullscreen if running on a Mac.
*
* @param gui The gui to enable the fullscreen on.
*/
public static void tryEnableFullscreen(JFrame gui)
{
if (OSType.getOSType() == OSType.MacOS)
{
FullScreenUtilities.addFullScreenListenerTo(gui, new FullScreenAdapter()
{
@Override
public void windowEnteredFullScreen(FullScreenEvent e)
{
log.debug("Window entered fullscreen mode--setting extended state to {}", JFrame.MAXIMIZED_BOTH);
gui.setExtendedState(JFrame.MAXIMIZED_BOTH);
}

@Override
public void windowExitedFullScreen(FullScreenEvent e)
{
log.debug("Window exited fullscreen mode--setting extended state to {}", JFrame.NORMAL);
gui.setExtendedState(JFrame.NORMAL);
}
});
FullScreenUtilities.setWindowCanFullScreen(gui, true);
log.debug("Enabled fullscreen on macOS");
}
Expand Down

0 comments on commit 1030e14

Please sign in to comment.