fix icon pixmap on child schematic windows

This commit is contained in:
Stefan Frederik 2021-11-17 22:15:36 +01:00
parent dcae02e8c4
commit daf90b0645
4 changed files with 18 additions and 16 deletions

View File

@ -2440,7 +2440,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(!strcmp(argv[1],"windowid")) /* used by xschem.tcl for configure events */
{
cmd_found = 1;
windowid();
if(argc >= 3) {
windowid(argv[2]);
}
}
else if(!strcmp(argv[1],"windows"))

View File

@ -149,7 +149,8 @@ int window_state (Display *disp, Window win, char *arg) {/*{{{*/
/* ----------------------------------------------------------------------- */
void windowid()
/* used to set icon */
void windowid(const char *winpath)
{
int i;
Display *display;
@ -160,10 +161,11 @@ void windowid()
Window *framewin_child_ptr;
unsigned int framewindow_nchildren;
dbg(0, "windowid(): winpath=%s\n", winpath);
framewindow_nchildren =0;
mainwindow=Tk_MainWindow(interp);
display = Tk_Display(mainwindow);
tcleval( "winfo id .");
Tcl_VarEval(interp, "winfo id ", winpath, NULL);
sscanf(tclresult(), "0x%x", (unsigned int *) &ww);
framewin = ww;
XQueryTree(display, framewin, &rootwindow, &parent_of_topwindow, &framewin_child_ptr, &framewindow_nchildren);
@ -180,13 +182,13 @@ void windowid()
if(!cad_icon_pixmap) {
i=XpmCreatePixmapFromData(display,framewin, cad_icon,&cad_icon_pixmap, &cad_icon_mask, NULL);
dbg(1, "windowid(): creating icon pixmap returned: %d\n",i);
hints_ptr = XAllocWMHints();
hints_ptr->icon_pixmap = cad_icon_pixmap ;
hints_ptr->icon_mask = cad_icon_mask ;
hints_ptr->flags = IconPixmapHint | IconMaskHint;
XSetWMHints(display, parent_of_topwindow, hints_ptr);
XFree(hints_ptr);
}
hints_ptr = XAllocWMHints();
hints_ptr->icon_pixmap = cad_icon_pixmap ;
hints_ptr->icon_mask = cad_icon_mask ;
hints_ptr->flags = IconPixmapHint | IconMaskHint;
XSetWMHints(display, parent_of_topwindow, hints_ptr);
XFree(hints_ptr);
#endif
Tcl_SetResult(interp,"",TCL_STATIC);
}

View File

@ -1155,7 +1155,7 @@ extern int set_different_token(char **s,const char *new, const char *old, int ob
extern void print_hilight_net(int show);
extern void change_layer();
extern void launcher();
extern void windowid();
extern void windowid(const char *winpath);
extern void preview_window(const char *what, const char *tk_win_path, const char *filename);
extern void new_schematic(const char *what, const char *top_path, const char *tk_win_path, const char *filename);
extern int window_state (Display *disp, Window win, char *arg);

View File

@ -3478,11 +3478,11 @@ proc new_window {what {filename {}} {path {-}}} {
toplevel $path -bg {} -width 400 -height 400
build_widgets $path
pack_widgets $path ;# also does set_bindings $path.drw
set_bindings $path.drw
update
xschem new_schematic create $path $path.drw [abs_sym_path $filename]
# set bindings after creating new schematic otherwise
# a Configure or Expose event is sent before window setup completed.
set_bindings $path.drw
save_ctx $path.drw
return $path
} elseif { $what eq {destroy}} {
@ -3668,6 +3668,8 @@ global env has_x OS
###
### Tk event handling
###
# puts "set_binding: topwin=$topwin"
if {($OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] > 0 ) && [info exists has_x]} {
set parent [winfo toplevel $topwin]
@ -3692,11 +3694,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"
if { $topwin eq {.drw} } {
bind $topwin <Configure> "xschem windowid; xschem callback %W %T %x %y 0 %w %h 0"
} else {
bind $topwin <Configure> "xschem callback %W %T %x %y 0 %w %h 0"
}
bind $topwin <Configure> "xschem windowid $parent; 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"