From: H.G. Muller Date: Sat, 25 Feb 2012 20:14:03 +0000 (+0100) Subject: Use more reliable X-call for getting window position X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=c6dc8d81c81b393e2de7eaebd356966db34c2008 Use more reliable X-call for getting window position XtGetValues on XtNx, XtNy is unreliable. XGetWindowAttributes seems to give more reliable results, and automatically accounts for the width of window dressing. The -frameX/Y options are no longer needed bcause of this, and were removed. --- diff --git a/args.h b/args.h index b8061d9..713e2ab 100644 --- a/args.h +++ b/args.h @@ -104,7 +104,6 @@ IcsTextMenuEntry icsTextMenuEntry[ICS_TEXT_MENU_SIZE]; int junk; Boolean singleList; char *homeDir; -int frameX, frameY; // width of window frame and title bar void EnsureOnScreen(int *x, int *y, int minX, int minY); char StringGet(void *getClosure); @@ -718,8 +717,6 @@ ArgDescriptor argDescriptors[] = { // [HGM] placement: put all window layouts last in ini file, but man X,Y before all others { "minX", ArgZ, (void *) &minX, FALSE, INVALID }, // [HGM] placement: to make sure auxiliary windows can be placed { "minY", ArgZ, (void *) &minY, FALSE, INVALID }, - { "frameX", ArgInt, (void *) &frameX, XBOARD, (ArgIniType) 2 }, // [HGM] placement: correction for lying X11 - { "frameY", ArgInt, (void *) &frameY, XBOARD, (ArgIniType) 22 }, { "winWidth", ArgInt, (void *) &wpMain.width, TRUE, INVALID }, // [HGM] placement: dummies to remember right & bottom { "winHeight", ArgInt, (void *) &wpMain.height, TRUE, INVALID }, // for attaching auxiliary windows to them { "x", ArgInt, (void *) &wpMain.x, TRUE, (ArgIniType) CW_USEDEFAULT }, diff --git a/xboard.c b/xboard.c index a1a41b9..77a73c4 100644 --- a/xboard.c +++ b/xboard.c @@ -1562,20 +1562,19 @@ GetActualPlacement (Widget wg, WindowPlacement *wp) Arg args[16]; Dimension w, h; Position x, y; - int i; + XWindowAttributes winAt; + Window win, dummy; + int i, rx, ry; if(!wg) return; - i = 0; - XtSetArg(args[i], XtNx, &x); i++; - XtSetArg(args[i], XtNy, &y); i++; - XtSetArg(args[i], XtNwidth, &w); i++; - XtSetArg(args[i], XtNheight, &h); i++; - XtGetValues(wg, args, i); - wp->x = x - frameX; - wp->y = y - frameY; - wp->height = h; - wp->width = w; + win = XtWindow(wg); + XGetWindowAttributes(xDisplay, win, &winAt); // this works, where XtGetValues on XtNx, XtNy does not! + XTranslateCoordinates (xDisplay, win, winAt.root, -winAt.border_width, -winAt.border_width, &rx, &ry, &dummy); + wp->x = rx - winAt.x; + wp->y = ry - winAt.y; + wp->height = winAt.height; + wp->width = winAt.width; } void