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 committed Mar 6, 2024
1 parent 0532901 commit 0b11e07
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ public void setBoundsSize(NSSize newSize) {
OS.objc_msgSend(this.id, OS.sel_setBoundsSize_, newSize);
}

public void setClipsToBounds(boolean clipsToBounds) {
OS.objc_msgSend(this.id, OS.sel_setClipsToBounds_, clipsToBounds);
}

public void setFocusRingType(long focusRingType) {
OS.objc_msgSend(this.id, OS.sel_setFocusRingType_, focusRingType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ public static int VERSION (int major, int minor, int bugfix) {

public static final long class_NSToolbarView = objc_getClass("NSToolbarView");

/** Since macOS 14 the clipsToBounds property of NSView is exposed */
public static final long sel_setClipsToBounds_ = Selector.sel_setClipsToBounds_.value;

/*
* Wrapper function which will call NSSavePanel.beginSheetModalForWindow. This
* implementation allows passing of objective-C block from Java to C code, and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public enum Selector {

, sel_awtAppDelegate("awtAppDelegate")

/** Since macOS 14 the clipsToBounds property of NSView is exposed */
, sel_setClipsToBounds_("setClipsToBounds:")

/** This section is auto generated */

, sel_CGEvent("CGEvent")
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
*/
view.setClipsToBounds(true);

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

0 comments on commit 0b11e07

Please sign in to comment.