various fixes in persistent window geometry save
This commit is contained in:
parent
e8d29c9b42
commit
63d1897050
|
|
@ -1044,7 +1044,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
int force = 0;
|
||||
const char *exit_status = "0";
|
||||
|
||||
|
||||
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
|
||||
for(i = 2; i < argc; ++i) {
|
||||
if(!strcmp(argv[i], "closewindow")) closewindow = 1;
|
||||
|
|
@ -1063,6 +1062,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
": UNSAVED data: want to exit?\"");
|
||||
}
|
||||
if(force || !xctx->modified || !strcmp(tclresult(), "ok")) {
|
||||
if(has_x) tcleval("store_geom . [xschem get schname]");
|
||||
swap_windows(0);
|
||||
set_modify(0); /* set modified status to 0 to avoid another confirm in following line */
|
||||
new_schematic("destroy", xctx->current_win_path, NULL, 0);
|
||||
|
|
@ -1077,10 +1077,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
if(force || !xctx->modified || !strcmp(tclresult(), "ok")) {
|
||||
if(closewindow) {
|
||||
char s[40];
|
||||
my_snprintf(s, S(s), "exit %s", exit_status);
|
||||
my_snprintf(s, S(s), "exit %s", exit_status); /* xwin_exit() saves window geometry */
|
||||
tcleval(s);
|
||||
}
|
||||
else clear_schematic(0, 0);
|
||||
else {
|
||||
if(has_x) tcleval("store_geom . [xschem get schname]");
|
||||
clear_schematic(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1095,6 +1098,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
": UNSAVED data: want to exit?\"");
|
||||
}
|
||||
if(!has_x || force || !xctx->modified || !strcmp(tclresult(), "ok")) {
|
||||
if(has_x) tcleval("store_geom . [xschem get schname]");
|
||||
swap_tabs();
|
||||
set_modify(0);
|
||||
new_schematic("destroy", xctx->current_win_path, NULL, 1);
|
||||
|
|
@ -1108,15 +1112,20 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
if(!has_x || force || !xctx->modified || !strcmp(tclresult(), "ok")) {
|
||||
if(closewindow) {
|
||||
char s[40];
|
||||
my_snprintf(s, S(s), "exit %s", exit_status);
|
||||
my_snprintf(s, S(s), "exit %s", exit_status); /* xwin_exit() saves window geometry */
|
||||
tcleval(s);
|
||||
}
|
||||
else clear_schematic(0, 0);
|
||||
else {
|
||||
if(has_x) tcleval("store_geom . [xschem get schname]");
|
||||
clear_schematic(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(force) set_modify(0); /* avoid ask to save downstream */
|
||||
if(has_x) tclvareval("store_geom ", xctx->top_path[0] ? xctx->top_path : ".",
|
||||
" [xschem get schname]", NULL);
|
||||
new_schematic("destroy", xctx->current_win_path, NULL, 1);
|
||||
}
|
||||
Tcl_SetResult(interp, my_itoa(get_window_count()), TCL_VOLATILE);
|
||||
|
|
|
|||
16
src/xinit.c
16
src/xinit.c
|
|
@ -1420,7 +1420,6 @@ void swap_windows(int dr)
|
|||
char wp_i[WINDOW_PATH_SIZE], wp_j[WINDOW_PATH_SIZE];
|
||||
Window window;
|
||||
int i = 0, j;
|
||||
Tk_Window tkwin, mainwindow;
|
||||
char geometry[80];
|
||||
|
||||
for(j = 1; j < MAX_NEW_WINDOWS; j++) {
|
||||
|
|
@ -1439,16 +1438,10 @@ void swap_windows(int dr)
|
|||
my_snprintf(wp_i, S(wp_i), "%s", save_xctx[i]->current_win_path); /* primary (.drw) window */
|
||||
my_snprintf(wp_j, S(wp_j), "%s", save_xctx[j]->current_win_path); /* sub (.x?.drw) window */
|
||||
|
||||
mainwindow = Tk_MainWindow(interp);
|
||||
/* get parent of wp_j window, since window manager reparents application windows to a
|
||||
* parent window with title bar and borders. This gives accurate geometry data */
|
||||
tkwin = Tk_Parent(Tk_NameToWindow(interp, wp_j, mainwindow));
|
||||
|
||||
/* get sub-window geometry and position. primary window wp_i will be sized and moved there. */
|
||||
dbg(1, "swap_windows(): %s: %dx%d+%d+%d\n",
|
||||
wp_j, Tk_Width(tkwin), Tk_Height(tkwin), Tk_X(tkwin), Tk_Y(tkwin));
|
||||
my_snprintf(geometry, S(geometry), "%dx%d+%d+%d",
|
||||
Tk_Width(tkwin), Tk_Height(tkwin), Tk_X(tkwin), Tk_Y(tkwin));
|
||||
tclvareval("wm geometry ", save_xctx[j]->top_path, NULL);
|
||||
my_snprintf(geometry, S(geometry), "%s", tclresult());
|
||||
dbg(1, "geometry=%s\n", geometry);
|
||||
|
||||
/* swap tcl contexts */
|
||||
tclvareval("save_ctx ", xctx->current_win_path, NULL);
|
||||
|
|
@ -1884,9 +1877,6 @@ static void destroy_window(int *window_count, const char *win_path)
|
|||
tclvareval("winfo toplevel ", win_path, NULL);
|
||||
my_strdup2(_ALLOC_ID_, &toplevel, tclresult());
|
||||
}
|
||||
|
||||
tclvareval("store_geom ", toplevel, " [xschem get schname]" , NULL);
|
||||
|
||||
delete_schematic_data(1);
|
||||
save_xctx[n] = NULL;
|
||||
if(has_x) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue