Skip to content

Commit

Permalink
Fix for Mac drawing bug issue 1012
Browse files Browse the repository at this point in the history
- Add a new selector setClipsToBounds
- Set this selector to true in Widget#drawRect
- See #1012
  • Loading branch information
Phillipus authored and merks committed Mar 11, 2024
1 parent cca2034 commit d06d1a1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public static int VERSION (int major, int minor, int bugfix) {
public static final long sel_setStyle = Selector.sel_setStyle.value;
public static final int NSTableViewStylePlain = 4;

/** 14.0 selector */
public static final long sel_setClipsToBounds_ = Selector.sel_setClipsToBounds_.value;

/* AWT application delegate. Remove these when JavaRuntimeSupport.framework has bridgesupport generated for it. */
public static final long class_JRSAppKitAWT = objc_getClass("JRSAppKitAWT");
public static final long sel_awtAppDelegate = Selector.sel_awtAppDelegate.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public enum Selector {
/** 11.0 selector */
, sel_setStyle("setStyle:")

/** 14.0 selector */
, sel_setClipsToBounds_("setClipsToBounds:")

, sel_awtAppDelegate("awtAppDelegate")

/** This section is auto generated */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,13 @@ void drawRect (long id, long sel, NSRect rect) {
if (!isDrawing()) return;
Display display = this.display;
NSView view = new NSView(id);

/*
* Since macOS 14 the clipsToBounds property of NSView has to be set to true
* See https://developer.apple.com/documentation/macos-release-notes/appkit-release-notes-for-macos-14
*/
OS.objc_msgSend(id, OS.sel_setClipsToBounds_, true);

display.isPainting.addObject(view);
NSGraphicsContext context = NSGraphicsContext.currentContext();
context.saveGraphicsState();
Expand Down

0 comments on commit d06d1a1

Please sign in to comment.