diff --git a/bleh_darwin.m b/bleh_darwin.m index 699f177..5a2cbcf 100644 --- a/bleh_darwin.m +++ b/bleh_darwin.m @@ -29,6 +29,20 @@ These are the objc_msgSend() wrappers around NSRect. The problem is that while o I use int64_t for maximum safety, as my coordinates are stored as Go ints and Go int -> C int (which is what is documented as happening) isn't reliable. */ +struct xrect objc_msgSend_stret_rect_noargs(id obj, SEL sel) +{ + NSRect s; + struct xrect t; + + objc_msgSend_stret(&s, obj, sel); + t.x = (int64_t) s.origin.x; + t.y = (int64_t) s.origin.y; + t.width = (int64_t) s.size.width; + t.height = (int64_t) s.size.height; + return t; +} + + #define OurRect() (NSMakeRect((CGFloat) x, (CGFloat) y, (CGFloat) w, (CGFloat) h)) id _objc_msgSend_rect(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h) diff --git a/objc_darwin.h b/objc_darwin.h index e73687e..173f238 100644 --- a/objc_darwin.h +++ b/objc_darwin.h @@ -21,6 +21,15 @@ inline id objc_msgSend_noargs(id obj, SEL sel) return objc_msgSend(obj, sel); } +struct xrect { + int64_t x; + int64_t y; + int64_t width; + int64_t height; +}; + +extern struct xrect objc_msgSend_stret_rect_noargs(id obj, SEL sel); + struct xsize { int64_t width; int64_t height; diff --git a/sysdata_darwin.go b/sysdata_darwin.go index 3456580..c50eeed 100644 --- a/sysdata_darwin.go +++ b/sysdata_darwin.go @@ -38,6 +38,7 @@ var ( _title = sel_getUid("title") _stringValue = sel_getUid("stringValue") // TODO others + _frame = sel_getUid("_frame") _setFrameDisplay = sel_getUid("setFrame:display:") ) @@ -219,8 +220,9 @@ func (s *sysData) setWindowSize(width int, height int) error { defer close(ret) uitask <- func() { // we need to get the top left point + r := C.objc_msgSend_stret_rect_noargs(s.id, _frame) objc_msgSend_rect_bool(s.id, _setFrameDisplay, - x, y, width, height, + int(r.x), int(r.y), width, height, C.BOOL(C.YES)) // TODO set to NO to prevent subviews from being redrawn before they are resized? ret <- struct{}{} }