From daf90b0645e5aedb8d847df70a5b9ce529170fdb Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Wed, 17 Nov 2021 22:15:36 +0100 Subject: [PATCH] fix icon pixmap on child schematic windows --- src/scheduler.c | 4 +++- src/xinit.c | 18 ++++++++++-------- src/xschem.h | 2 +- src/xschem.tcl | 10 ++++------ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index 88873ddd..7ba030d8 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -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")) diff --git a/src/xinit.c b/src/xinit.c index 39fe59bc..0b1194db 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -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); } diff --git a/src/xschem.h b/src/xschem.h index 97023228..d31e30b1 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -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); diff --git a/src/xschem.tcl b/src/xschem.tcl index 1a4aab7f..a83ab2ab 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -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 "xschem callback %W -3 %x %y 0 %b 0 %s" bind $topwin "xschem callback %W -3 %x %y 0 %b 0 %s" bind $topwin "xschem callback %W -3 %x %y 0 %b 0 %s" - if { $topwin eq {.drw} } { - bind $topwin "xschem windowid; xschem callback %W %T %x %y 0 %w %h 0" - } else { - bind $topwin "xschem callback %W %T %x %y 0 %w %h 0" - } + bind $topwin "xschem windowid $parent; xschem callback %W %T %x %y 0 %w %h 0" bind $topwin "xschem callback %W %T %x %y 0 %b 0 %s" bind $topwin "xschem callback %W %T %x %y 0 %b 0 %s" bind $topwin "xschem callback %W %T %x %y %N 0 0 %s"