diff --git a/collects/mred/private/wxtop.ss b/collects/mred/private/wxtop.ss index f24b14b6d0..dc802f7711 100644 --- a/collects/mred/private/wxtop.ss +++ b/collects/mred/private/wxtop.ss @@ -31,14 +31,21 @@ (wx:display-size xb yb (if full-screen? 1 0)) (values (unbox xb) (unbox yb))))) - (define (get-display-left-top-inset) - (let ([xb (box 0)] - [yb (box 0)]) - (wx:display-origin xb yb) - (values (unbox xb) (unbox yb)))) + (define get-display-left-top-inset + (opt-lambda ([advisory? #f]) + (let ([xb (box 0)] + [yb (box 0)]) + (wx:display-origin xb yb advisory?) + (values (unbox xb) (unbox yb))))) - (define top-x 1) - (define top-y 1) + (define-values (init-top-x init-top-y) + (let-values ([(x y) (get-display-left-top-inset #f)] + [(x2 y2) (get-display-left-top-inset #t)]) + (values (+ 1 (- x2 x)) + (+ 1 (- y2 y))))) + + (define top-x init-top-x) + (define top-y init-top-y) (define top-level-windows (make-hash-table 'weak)) ;; make-top-container%: adds the necessary functionality to wx:frame% and @@ -340,8 +347,8 @@ (values top-y #f) (values (max 0 (- sh h 20)) #t))]) (move x y) - (set! top-x (if x-reset? 0 (+ top-x 10))) - (set! top-y (if y-reset? 0 (+ top-y 20))))) + (set! top-x (if x-reset? init-top-x (+ top-x 10))) + (set! top-y (if y-reset? init-top-y (+ top-y 20))))) (if on? (hash-table-put! top-level-windows this #t) (hash-table-remove! top-level-windows this)) diff --git a/src/mred/wxs/wxs_glob.cxx b/src/mred/wxs/wxs_glob.cxx index b98226f382..7f579161bf 100644 --- a/src/mred/wxs/wxs_glob.cxx +++ b/src/mred/wxs/wxs_glob.cxx @@ -59,6 +59,15 @@ static void wxCancelQuit() #endif } +static void wxsDisplayOrigin(int *x, int *y, Bool flags = FALSE) +{ +#ifdef wx_mac + wxDisplayOrigin(x, y, flags); +#else + wxDisplayOrigin(x, y); +#endif +} + #ifndef wxGETDIR # define wxGETDIR 0 #endif @@ -480,7 +489,7 @@ static Scheme_Object *wxsGlobalwxStripMenuCodes_Scheme(int n, Scheme_Object *p[ return WITH_REMEMBERED_STACK(objscheme_bundle_string((char *)r)); } -static Scheme_Object *wxsGlobalwxDisplayOrigin(int n, Scheme_Object *p[]) +static Scheme_Object *wxsGlobalwxsDisplayOrigin(int n, Scheme_Object *p[]) { WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p) REMEMBER_VAR_STACK(); @@ -488,6 +497,7 @@ static Scheme_Object *wxsGlobalwxDisplayOrigin(int n, Scheme_Object *p[]) int* x0 = &_x0; int _x1; int* x1 = &_x1; + Bool x2; Scheme_Object *sbox_tmp; SETUP_VAR_STACK_REMEMBERED(1); @@ -496,9 +506,13 @@ static Scheme_Object *wxsGlobalwxDisplayOrigin(int n, Scheme_Object *p[]) *x0 = (sbox_tmp = WITH_VAR_STACK(objscheme_unbox(p[0+0], "display-origin")), WITH_VAR_STACK(objscheme_unbundle_integer(sbox_tmp, "display-origin"", extracting boxed argument"))); *x1 = (sbox_tmp = WITH_VAR_STACK(objscheme_unbox(p[0+1], "display-origin")), WITH_VAR_STACK(objscheme_unbundle_integer(sbox_tmp, "display-origin"", extracting boxed argument"))); + if (n > (0+2)) { + x2 = WITH_VAR_STACK(objscheme_unbundle_bool(p[0+2], "display-origin")); + } else + x2 = FALSE; - WITH_VAR_STACK(wxDisplayOrigin(x0, x1)); + WITH_VAR_STACK(wxsDisplayOrigin(x0, x1, x2)); if (n > (0+0)) @@ -762,7 +776,7 @@ void objscheme_setup_wxsGlobal(Scheme_Env *env) WITH_VAR_STACK(scheme_install_xc_global("get-resource", functmp, env)); functmp = WITH_VAR_STACK(scheme_make_prim_w_arity((Scheme_Prim *)wxsGlobalwxStripMenuCodes_Scheme, "label->plain-label", 1, 1)); WITH_VAR_STACK(scheme_install_xc_global("label->plain-label", functmp, env)); - functmp = WITH_VAR_STACK(scheme_make_prim_w_arity((Scheme_Prim *)wxsGlobalwxDisplayOrigin, "display-origin", 2, 2)); + functmp = WITH_VAR_STACK(scheme_make_prim_w_arity((Scheme_Prim *)wxsGlobalwxsDisplayOrigin, "display-origin", 2, 3)); WITH_VAR_STACK(scheme_install_xc_global("display-origin", functmp, env)); functmp = WITH_VAR_STACK(scheme_make_prim_w_arity((Scheme_Prim *)wxsGlobalwxDisplaySize, "display-size", 3, 3)); WITH_VAR_STACK(scheme_install_xc_global("display-size", functmp, env)); diff --git a/src/mred/wxs/wxs_glob.xc b/src/mred/wxs/wxs_glob.xc index 97f32eacac..4185f95bca 100644 --- a/src/mred/wxs/wxs_glob.xc +++ b/src/mred/wxs/wxs_glob.xc @@ -33,6 +33,15 @@ static void wxCancelQuit() #endif } +static void wxsDisplayOrigin(int *x, int *y, Bool flags = FALSE) +{ +#ifdef wx_mac + wxDisplayOrigin(x, y, flags); +#else + wxDisplayOrigin(x, y); +#endif +} + #ifndef wxGETDIR # define wxGETDIR 0 #endif @@ -112,7 +121,7 @@ extern class wxDialogBox *objscheme_unbundle_wxDialogBox(Scheme_Object *obj, con @ "hide-cursor" : void wxHideCursor() @ "bell" : void wxBell(); @ "display-size" : void wxDisplaySize(int*,int*,int); -@ "display-origin" : void wxDisplayOrigin(int*,int*); +@ "display-origin" : void wxsDisplayOrigin(int*,int*,bool=FALSE); @ "label->plain-label" : string wxStripMenuCodes_Scheme(string); diff --git a/src/wxmac/include/base/wb_gdi.h b/src/wxmac/include/base/wb_gdi.h index abe9520b6e..cfbf001b18 100644 --- a/src/wxmac/include/base/wb_gdi.h +++ b/src/wxmac/include/base/wb_gdi.h @@ -371,7 +371,7 @@ extern Bool wxColourDisplay(void); extern int wxDisplayDepth(void); extern void wxDisplaySize(int *width, int *height, int flags = 0); -extern void wxDisplayOrigin(int *x, int *y); +extern void wxDisplayOrigin(int *x, int *y, int flags = 0); extern void wxSetCursor(wxCursor *cursor); diff --git a/src/wxmac/src/mac/wx_gdi.cc b/src/wxmac/src/mac/wx_gdi.cc index 719f7a17fc..2051cd1a41 100644 --- a/src/wxmac/src/mac/wx_gdi.cc +++ b/src/wxmac/src/mac/wx_gdi.cc @@ -874,21 +874,27 @@ void wxDisplaySize(int *width, int *height, int flags) BitMap screenBits; int mbh; - GetQDGlobalsScreenBits(&screenBits); - *width = screenBits.bounds.right - screenBits.bounds.left; - if (flags) - mbh = 0; - else - mbh = wxMenuBarHeight; - *height = screenBits.bounds.bottom - screenBits.bounds.top - mbh; + if (!flags) { + Rect r; + GetAvailableWindowPositioningBounds(NULL, &r); + *width = (r.right - r.left); + *height = (r.bottom - wxMenuBarHeight); + } else { + GetQDGlobalsScreenBits(&screenBits); + *width = screenBits.bounds.right - screenBits.bounds.left; + *height = screenBits.bounds.bottom - screenBits.bounds.top; + } } -void wxDisplayOrigin(int *x, int *y) +void wxDisplayOrigin(int *x, int *y, int flags) { - int mbh; - *x = 0; - mbh = wxMenuBarHeight; - *y = mbh; + if (flags) { + Rect r; + GetAvailableWindowPositioningBounds(NULL, &r); + *x = r.left; + } else + *x = 0; + *y = wxMenuBarHeight; } static void FreeGWorld(GWorldPtr x_pixmap)