From: H.G. Muller Date: Wed, 20 Feb 2013 09:08:09 +0000 (+0100) Subject: Better handling of undefined window parameters X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=204df43a817c927d4db73f81cd4b4ce5075def6b;p=xboard.git Better handling of undefined window parameters Repositioning and resizing a newly created dialog was based on the width parameter of the stored sizing info being valid. Now it is separately tested if the position is valid, so that sizing and moving can be done independently. This allows us to store position info, but not size info for the slave board, so that it automatically will use the size of the main board when first opened. --- diff --git a/args.h b/args.h index 469bc49..f6e755b 100644 --- a/args.h +++ b/args.h @@ -775,8 +775,8 @@ ArgDescriptor argDescriptors[] = { #if XBOARD { "slaveX", ArgX, (void *) &wpDualBoard.x, TRUE, (ArgIniType) CW_USEDEFAULT }, { "slaveY", ArgY, (void *) &wpDualBoard.y, TRUE, (ArgIniType) CW_USEDEFAULT }, - { "slaveW", ArgInt, (void *) &wpDualBoard.width, TRUE, (ArgIniType) CW_USEDEFAULT }, - { "slaveH", ArgInt, (void *) &wpDualBoard.height, TRUE, (ArgIniType) CW_USEDEFAULT }, + { "slaveW", ArgInt, (void *) &wpDualBoard.width, FALSE, (ArgIniType) CW_USEDEFAULT }, + { "slaveH", ArgInt, (void *) &wpDualBoard.height, FALSE, (ArgIniType) CW_USEDEFAULT }, #endif /* [AS] Layout stuff */ { "moveHistoryUp", ArgBoolean, (void *) &wpMoveHistory.visible, TRUE, (ArgIniType) TRUE }, diff --git a/gtk/xoptions.c b/gtk/xoptions.c index 0f90d6e..18fc857 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -1525,11 +1525,11 @@ if(appData.debugMode) printf("n=%d, h=%d, w=%d\n",n,height,width); (gpointer)(intptr_t) dlgNr); shellUp[dlgNr]++; - if(dlgNr && wp[dlgNr] && wp[dlgNr]->width > 0) { // if persistent window-info available, reposition + if(dlgNr && wp[dlgNr]) { // if persistent window-info available, reposition + if(wp[dlgNr]->x > 0 && wp[dlgNr]->y > 0) gtk_window_move(GTK_WINDOW(dialog), wp[dlgNr]->x, wp[dlgNr]->y); -//printf("moved %d to (%d,%d)\n", dlgNr, wp[dlgNr]->x, wp[dlgNr]->y); + if(wp[dlgNr]->width > 0 && wp[dlgNr]->height > 0) gtk_window_resize(GTK_WINDOW(dialog), wp[dlgNr]->width, wp[dlgNr]->height); -//printf("resized %d to %dx%d\n", dlgNr, wp[dlgNr]->width, wp[dlgNr]->height); } return 1; // tells caller he must do initialization (e.g. add specific event handlers) diff --git a/xaw/xoptions.c b/xaw/xoptions.c index 1353b8b..d0fdafc 100644 --- a/xaw/xoptions.c +++ b/xaw/xoptions.c @@ -1225,13 +1225,17 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent shellUp[dlgNr]++; // count rather than flag previous = NULL; if(textField) SetFocus(textField, popup, (XEvent*) NULL, False); - if(dlgNr && wp[dlgNr] && wp[dlgNr]->width > 0) { // if persistent window-info available, reposition + if(dlgNr && wp[dlgNr]) { // if persistent window-info available, reposition j = 0; - XtSetArg(args[j], XtNheight, (Dimension) (wp[dlgNr]->height)); j++; - XtSetArg(args[j], XtNwidth, (Dimension) (wp[dlgNr]->width)); j++; - XtSetArg(args[j], XtNx, (Position) (wp[dlgNr]->x)); j++; - XtSetArg(args[j], XtNy, (Position) (wp[dlgNr]->y)); j++; - XtSetValues(popup, args, j); + if(wp[dlgNr]->width > 0 && wp[dlgNr]->height > 0) { + XtSetArg(args[j], XtNheight, (Dimension) (wp[dlgNr]->height)); j++; + XtSetArg(args[j], XtNwidth, (Dimension) (wp[dlgNr]->width)); j++; + } + if(wp[dlgNr]->width > 0 && wp[dlgNr]->y > 0) { + XtSetArg(args[j], XtNx, (Position) (wp[dlgNr]->x)); j++; + XtSetArg(args[j], XtNy, (Position) (wp[dlgNr]->y)); j++; + } + if(j) XtSetValues(popup, args, j); } RaiseWindow(dlgNr); return 1; // tells caller he must do initialization (e.g. add specific event handlers)