From 642ee525ac888cbd67ccf3b459084e1fc326209b Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 21 Mar 2024 22:37:39 +0100 Subject: [PATCH] fix grab screen window pathname calculation --- src/callback.c | 8 ++------ src/scheduler.c | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/callback.c b/src/callback.c index a5fa0036..fc6cf28f 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1800,7 +1800,6 @@ static int grabscreen(const char *winpath, int event, int mx, int my, KeySym key } if(grab_state == 1 && event == ButtonRelease) { - char *top_path; int grab_w = 0, grab_h = 0; cairo_surface_t *sfc = NULL, *subsfc = NULL; png_to_byte_closure_t closure; @@ -1808,7 +1807,6 @@ static int grabscreen(const char *winpath, int event, int mx, int my, KeySym key size_t olength; char *prop = NULL; - top_path = xctx->top_path[0] ? xctx->top_path : "."; grab_state = 0; first_motion = 1; @@ -1817,7 +1815,7 @@ static int grabscreen(const char *winpath, int event, int mx, int my, KeySym key x2 = rmx; y2 = rmy; INT_RECTORDER(x1, y1, x2, y2); - tclvareval("grab release ", top_path, "drw", NULL); + tclvareval("grab release ", xctx->top_path, ".drw", NULL); if(x2 - x1 > 10 && y2 -y1 > 10) { grab_w = (x2 - x1 + 1); grab_h = (y2 - y1 + 1); @@ -2850,10 +2848,8 @@ int rstate; /* (reduced state, without ShiftMask) */ } #if defined(__unix__) && HAS_CAIRO==1 if(key == XK_Print) { - char *top_path; - top_path = xctx->top_path[0] ? xctx->top_path : "."; xctx->ui_state |= GRABSCREEN; - tclvareval("grab set -global ", top_path, "drw", NULL); + tclvareval("grab set -global ", xctx->top_path, ".drw", NULL); break; } #endif diff --git a/src/scheduler.c b/src/scheduler.c index fc5e32bf..4af58602 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1912,12 +1912,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg * grab root window */ else if(!strcmp(argv[1], "grabscreen")) { - char *top_path; if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} - top_path = xctx->top_path[0] ? xctx->top_path : "."; #if defined(__unix__) && HAS_CAIRO==1 xctx->ui_state |= GRABSCREEN; - tclvareval("grab set -global ", top_path, "drw", NULL); + tclvareval("grab set -global ", xctx->top_path, ".drw", NULL); #endif Tcl_ResetResult(interp); }