Fixed Mac OS X sysData.setWindowSize() to get the window origin. Now to fix the rest of the errors...

This commit is contained in:
Pietro Gagliardi 2014-03-01 13:58:38 -05:00
parent 0770c2a697
commit 00243442d2
3 changed files with 26 additions and 1 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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{}{}
}