check for max number of subwindows, better way to set icons for windows
This commit is contained in:
parent
d1a922643d
commit
bbba3b9c02
18
src/xinit.c
18
src/xinit.c
|
|
@ -24,6 +24,8 @@
|
|||
#ifdef __unix__
|
||||
#include <pwd.h> /* getpwuid */
|
||||
#endif
|
||||
/* max number of windows (including main) a single xschem process can handle */
|
||||
#define MAX_NEW_WINDOWS 20
|
||||
|
||||
static int init_done=0; /* 20150409 to avoid double call by Xwindows close and TclExitHandler */
|
||||
static XSetWindowAttributes winattr;
|
||||
|
|
@ -161,7 +163,7 @@ void windowid(const char *winpath)
|
|||
Window *framewin_child_ptr;
|
||||
unsigned int framewindow_nchildren;
|
||||
|
||||
dbg(0, "windowid(): winpath=%s\n", winpath);
|
||||
dbg(1, "windowid(): winpath=%s\n", winpath);
|
||||
framewindow_nchildren =0;
|
||||
mainwindow=Tk_MainWindow(interp);
|
||||
display = Tk_Display(mainwindow);
|
||||
|
|
@ -834,7 +836,6 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
|
|||
}
|
||||
}
|
||||
|
||||
#define MAX_NEW_WINDOWS 20
|
||||
|
||||
/* top_path is the path prefix of tk_win_path:
|
||||
*
|
||||
|
|
@ -861,7 +862,10 @@ void new_schematic(const char *what, const char *top_path, const char *tk_win_pa
|
|||
save_xctx[0] = xctx; /* save current schematic */
|
||||
tknew_window[0] = Tk_NameToWindow(interp, ".drw", mainwindow);
|
||||
}
|
||||
if(cnt + 1 >= MAX_NEW_WINDOWS) return; /* no more free slots */
|
||||
if(cnt + 1 >= MAX_NEW_WINDOWS) {
|
||||
dbg(0, "new_schematic(\"create\"...): no more free slots\n");
|
||||
return; /* no more free slots */
|
||||
}
|
||||
cnt++;
|
||||
n = -1;
|
||||
for(i = 1; i < MAX_NEW_WINDOWS; i++) { /* search 1st free slot */
|
||||
|
|
@ -1665,6 +1669,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
my_snprintf(tmp, S(tmp), "%d", ControlMask);
|
||||
tclsetvar("ControlMask", tmp);
|
||||
#endif
|
||||
|
||||
|
||||
/* END X INITIALIZATION */
|
||||
|
||||
|
||||
|
|
@ -1675,7 +1681,9 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
/* Completing tk windows creation (see xschem.tcl, pack_widgets) and event binding */
|
||||
/* *AFTER* X initialization done */
|
||||
/* */
|
||||
if(has_x) tcleval("pack_widgets; set_bindings .drw");
|
||||
if(has_x) {
|
||||
tcleval("pack_widgets; set_bindings .drw");
|
||||
}
|
||||
|
||||
fs=tclgetintvar("fullscreen");
|
||||
if(fs) {
|
||||
|
|
@ -1736,7 +1744,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
load_schematic(1, filename, !do_netlist);
|
||||
}
|
||||
|
||||
|
||||
tclsetintvar("max_new_windows", MAX_NEW_WINDOWS);
|
||||
|
||||
zoom_full(0, 0, 1, 0.97); /* Necessary to tell xschem the initial area to display */
|
||||
xctx->pending_fullzoom=1;
|
||||
|
|
|
|||
|
|
@ -3462,11 +3462,17 @@ proc every {interval script} {
|
|||
}
|
||||
|
||||
proc new_window {what {filename {}} {path {-}}} {
|
||||
global max_new_windows
|
||||
if { $what eq {create}} {
|
||||
if {$tctx::cnt == 0} {
|
||||
save_ctx .drw
|
||||
}
|
||||
if {$tctx::cnt + 1 >= $max_new_windows} {
|
||||
puts "proc new_window: no more free slots"
|
||||
return
|
||||
}
|
||||
incr tctx::cnt
|
||||
|
||||
if {$path eq {-}} {
|
||||
for {set i 1} {$i <= $tctx::cnt} {incr i} {
|
||||
if {![winfo exists .x$i]} {
|
||||
|
|
@ -3484,6 +3490,7 @@ proc new_window {what {filename {}} {path {-}}} {
|
|||
# set bindings after creating new schematic otherwise
|
||||
# a Configure or Expose event is sent before window setup completed.
|
||||
save_ctx $path.drw
|
||||
xschem windowid $path ;# set icon for window
|
||||
return $path
|
||||
} elseif { $what eq {destroy}} {
|
||||
set path $filename
|
||||
|
|
@ -3693,7 +3700,7 @@ global env has_x OS
|
|||
bind $topwin <Double-Button-1> "xschem callback %W -3 %x %y 0 %b 0 %s"
|
||||
bind $topwin <Double-Button-2> "xschem callback %W -3 %x %y 0 %b 0 %s"
|
||||
bind $topwin <Double-Button-3> "xschem callback %W -3 %x %y 0 %b 0 %s"
|
||||
bind $topwin <Configure> "xschem windowid $parent; xschem callback %W %T %x %y 0 %w %h 0"
|
||||
bind $topwin <Configure> "xschem callback %W %T %x %y 0 %w %h 0"
|
||||
bind $topwin <ButtonPress> "xschem callback %W %T %x %y 0 %b 0 %s"
|
||||
bind $topwin <ButtonRelease> "xschem callback %W %T %x %y 0 %b 0 %s"
|
||||
bind $topwin <KeyPress> "xschem callback %W %T %x %y %N 0 0 %s"
|
||||
|
|
@ -4459,6 +4466,8 @@ set_ne to_png {gm convert}
|
|||
## ps to pdf conversion
|
||||
set_ne to_pdf {ps2pdf}
|
||||
|
||||
## max number of windows (including main) a single xschem process can handle
|
||||
set_ne max_new_windows -1 ;# this is set by xinit.c
|
||||
## remember edit_prop widget size
|
||||
set_ne edit_prop_size 80x12
|
||||
set_ne text_line_default_geometry 80x12
|
||||
|
|
@ -4614,6 +4623,9 @@ if { ( $OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] >
|
|||
|
||||
# allow user to modify key bindings
|
||||
set_replace_key_binding
|
||||
|
||||
update
|
||||
xschem windowid . ;# set icon for window
|
||||
} ;# end if {[exists has_x]}
|
||||
|
||||
# read custom colors
|
||||
|
|
|
|||
Loading…
Reference in New Issue