From 3bb9f4130576bb4f356b3e49fc73bc7d456d716d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 13 Apr 2014 20:16:05 -0400 Subject: [PATCH] Fixed Mac OS X so that window sizes do not include the titlebar and frame. --- bleh_darwin.m | 5 +++++ objc_darwin.h | 3 ++- sysdata_darwin.go | 10 ++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bleh_darwin.m b/bleh_darwin.m index f21d55c..b537603 100644 --- a/bleh_darwin.m +++ b/bleh_darwin.m @@ -172,6 +172,11 @@ struct xsize objc_msgSend_stret_size_noargs(id obj, SEL sel) return t; } +id objc_msgSend_size(id obj, SEL sel, int64_t width, int64_t height) +{ + return objc_msgSend(obj, sel, NSMakeSize((CGFloat) width, (CGFloat) height)); +} + /* and again for NSPoint */ diff --git a/objc_darwin.h b/objc_darwin.h index fbe169c..aaca07e 100644 --- a/objc_darwin.h +++ b/objc_darwin.h @@ -88,13 +88,14 @@ m1(ptr, void *) m1(bool, BOOL) extern id objc_msgSend_int(id obj, SEL sel, intptr_t a); m1(double, double) +extern id objc_msgSend_point(id obj, SEL sel, int64_t x, int64_t y); +extern id objc_msgSend_size(id objc, SEL sel, int64_t width, int64_t height); m2(id_id, id, id) extern id objc_msgSend_rect_bool(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h, BOOL b); extern id objc_msgSend_id_int(id obj, SEL sel, id a, intptr_t b); extern id objc_msgSend_id_uint(id obj, SEL sel, id a, uintptr_t b); m2(id_bool, id, BOOL) -extern id objc_msgSend_point(id obj, SEL sel, int64_t x, int64_t y); m3(id_id_id, id, id, id) m3(sel_id_bool, SEL, id, BOOL) diff --git a/sysdata_darwin.go b/sysdata_darwin.go index ed50132..acfe11e 100644 --- a/sysdata_darwin.go +++ b/sysdata_darwin.go @@ -60,7 +60,7 @@ var ( _title = sel_getUid("title") _stringValue = sel_getUid("stringValue") _frame = sel_getUid("frame") - _setFrameDisplay = sel_getUid("setFrame:display:") + _setContentSize = sel_getUid("setContentSize:") _setBezelStyle = sel_getUid("setBezelStyle:") _setTarget = sel_getUid("setTarget:") _setAction = sel_getUid("setAction:") @@ -519,11 +519,9 @@ func (s *sysData) setWindowSize(width int, height int) error { ret := make(chan struct{}) defer close(ret) uitask <- func() { - // we need to get the top left point - r := C.objc_msgSend_stret_rect_noargs(s.id, _frame) - C.objc_msgSend_rect_bool(s.id, _setFrameDisplay, - C.int64_t(r.x), C.int64_t(r.y), C.int64_t(width), C.int64_t(height), - C.BOOL(C.YES)) // TODO set to NO to prevent subviews from being redrawn before they are resized? + C.objc_msgSend_size(s.id, _setContentSize, + C.int64_t(width), C.int64_t(height)) + C.objc_msgSend_noargs(s.id, _display) // TODO needed? ret <- struct{}{} } <-ret