Skip to content

Commit

Permalink
POC fix for Mac drawing bug
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 4, 2024
1 parent 50d7ef7 commit b2b6a62
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ public void setBoundsSize(NSSize newSize) {
OS.objc_msgSend(this.id, OS.sel_setBoundsSize_, newSize);
}

//See https://github.com/eclipse-platform/eclipse.platform.swt/issues/1012
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 @@ -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;

/** See https://github.com/eclipse-platform/eclipse.platform.swt/issues/1012 */
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 @@ -84,6 +84,9 @@ public enum Selector {

, sel_awtAppDelegate("awtAppDelegate")

/** See https://github.com/eclipse-platform/eclipse.platform.swt/issues/1012 */
, 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,8 @@ void drawRect (long id, long sel, NSRect rect) {
if (!isDrawing()) return;
Display display = this.display;
NSView view = new NSView(id);
/** See https://github.com/eclipse-platform/eclipse.platform.swt/issues/1012 */
view.setClipsToBounds(true);
display.isPainting.addObject(view);
NSGraphicsContext context = NSGraphicsContext.currentContext();
context.saveGraphicsState();
Expand Down

0 comments on commit b2b6a62

Please sign in to comment.