From 364c2f1f3a8126fcbbb79b321a36f18a9b6e10f4 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Wed, 24 Nov 2021 01:07:33 +0100 Subject: [PATCH] moved functions containing X calls: now only callback.c, xinit.c and draw.c contain xorg-specific function calls. --- src/actions.c | 56 ++-------------------------------- src/move.c | 2 +- src/select.c | 28 ++--------------- src/xinit.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/xschem.h | 2 ++ 5 files changed, 91 insertions(+), 81 deletions(-) diff --git a/src/actions.c b/src/actions.c index 6fb538cc..d1aa4dae 100644 --- a/src/actions.c +++ b/src/actions.c @@ -211,58 +211,6 @@ void toggle_only_probes() draw(); } -void toggle_fullscreen(const char *topwin) -{ - char fullscr[]="add,fullscreen"; - char normal[]="remove,fullscreen"; - unsigned int topwin_id; - Window rootwindow, parent_id; - Window *framewin_child_ptr; - unsigned int framewindow_nchildren; - int fs; - - - if(!strcmp(topwin, ".drw")) { - tcleval( "winfo id ."); - sscanf(tclresult(), "0x%x", (unsigned int *) &topwin_id); - } else { - Tcl_VarEval(interp, "winfo id ", xctx->top_path, NULL); - sscanf(tclresult(), "0x%x", (unsigned int *) &topwin_id); - } - - XQueryTree(display, topwin_id, &rootwindow, &parent_id, &framewin_child_ptr, &framewindow_nchildren); - - - fs = tclgetintvar("fullscreen"); - fs = (fs+1)%2; - if(fs==1) tclsetvar("fullscreen","1"); - else if(fs==2) tclsetvar("fullscreen","2"); - else tclsetvar("fullscreen","0"); - - dbg(1, "toggle_fullscreen(): fullscreen=%d\n", fs); - if(fs==2) { - Tcl_VarEval(interp, "pack forget ", xctx->top_path, ".menubar ", xctx->top_path, ".statusbar; update", NULL); - xctx->menu_removed = 1; - } - if(fs !=2 && xctx->menu_removed) { - Tcl_VarEval(interp, "pack ", xctx->top_path, - ".menubar -anchor n -side top -fill x -before ", xctx->top_path, ".drw; pack ", - xctx->top_path, ".statusbar -after ", xctx->top_path, ".drw -anchor sw -fill x; update", NULL); - xctx->menu_removed=0; - } - - - if(fs == 1) { - window_state(display , parent_id,fullscr); - } else if(fs == 2) { - window_state(display , parent_id,normal); - window_state(display , parent_id,fullscr); - } else { - window_state(display , parent_id,normal); - } - xctx->pending_fullzoom=1; -} - #ifdef __unix__ void new_window(const char *cell, int symbol) { @@ -1353,7 +1301,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected) } } -/* flags: bit0: invoke change_linewidth()/XSetLineAttributes, bit1: centered zoom */ +/* flags: bit0: invoke change_linewidth()/xsetLineattributes, bit1: centered zoom */ void zoom_full(int dr, int sel, int flags, double shrink) { xRect boundbox; @@ -2018,7 +1966,7 @@ void new_rect(int what) drawrect(xctx->rectcolor, NOW, xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2, 0); save_draw = xctx->draw_window; xctx->draw_window = 1; - /* draw fill pattern even in XCopyArea mode */ + /* draw fill pattern even in xcopyarea mode */ filledrect(xctx->rectcolor, NOW, xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2); xctx->draw_window = save_draw; storeobject(-1, xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2,xRECT,xctx->rectcolor, 0, NULL); diff --git a/src/move.c b/src/move.c index b6335c8d..70d1f5fa 100644 --- a/src/move.c +++ b/src/move.c @@ -443,7 +443,7 @@ void draw_selection(GC g, int interruptable) break; } #ifdef __unix__ - if(XPending(display) && interruptable) + if(pending_events() && interruptable) { drawtemparc(g, END, 0.0, 0.0, 0.0, 0.0, 0.0); drawtemprect(g, END, 0.0, 0.0, 0.0, 0.0); diff --git a/src/select.c b/src/select.c index 3f219342..2ebdf02e 100644 --- a/src/select.c +++ b/src/select.c @@ -496,8 +496,6 @@ void delete_only_rect_line_arc_poly(void) void bbox(int what,double x1,double y1, double x2, double y2) { - int i; - /* fprintf(errfp, "bbox: what=%d\n", what); */ switch(what) { @@ -551,16 +549,7 @@ void bbox(int what,double x1,double y1, double x2, double y2) xctx->xrect[0].height = xctx->areah-4*INT_WIDTH(xctx->lw); if(has_x) { - XSetClipMask(display, xctx->gctiled, None); /* clipping already done in software */ - for(i=0;igc[i], None); /* clipping already done in software */ - XSetClipMask(display, xctx->gcstipple[i], None); /* optimization, clipping already done in software */ - } - #if HAS_CAIRO==1 - cairo_reset_clip(xctx->cairo_ctx); - cairo_reset_clip(xctx->cairo_save_ctx); - #endif + set_clip_mask(END); } xctx->sem=0; break; @@ -581,21 +570,8 @@ void bbox(int what,double x1,double y1, double x2, double y2) xctx->xrect[0].width = xctx->bbx2-xctx->bbx1+2*INT_WIDTH(xctx->lw); xctx->xrect[0].height = xctx->bby2-xctx->bby1+2*INT_WIDTH(xctx->lw); if(has_x) { - for(i=0;igc[i], 0,0, xctx->xrect, 1, Unsorted); - XSetClipRectangles(display, xctx->gcstipple[i], 0,0, xctx->xrect, 1, Unsorted); - } - XSetClipRectangles(display, xctx->gctiled, 0,0, xctx->xrect, 1, Unsorted); + set_clip_mask(SET); dbg(1, "bbox(): bbox= %d %d %d %d\n",xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2); - #if HAS_CAIRO==1 - cairo_rectangle(xctx->cairo_ctx, xctx->xrect[0].x, xctx->xrect[0].y, - xctx->xrect[0].width, xctx->xrect[0].height); - cairo_clip(xctx->cairo_ctx); - cairo_rectangle(xctx->cairo_save_ctx, xctx->xrect[0].x, xctx->xrect[0].y, - xctx->xrect[0].width, xctx->xrect[0].height); - cairo_clip(xctx->cairo_save_ctx); - #endif } break; default: diff --git a/src/xinit.c b/src/xinit.c index 2728e408..37802d46 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -736,6 +736,90 @@ int build_colors(double dim, double dim_bg) return 0; /* success */ } +void set_clip_mask(int what) +{ + int i; + if(what == SET) { + for(i=0;igc[i], 0,0, xctx->xrect, 1, Unsorted); + XSetClipRectangles(display, xctx->gcstipple[i], 0,0, xctx->xrect, 1, Unsorted); + } + XSetClipRectangles(display, xctx->gctiled, 0,0, xctx->xrect, 1, Unsorted); + #if HAS_CAIRO==1 + cairo_rectangle(xctx->cairo_ctx, xctx->xrect[0].x, xctx->xrect[0].y, + xctx->xrect[0].width, xctx->xrect[0].height); + cairo_clip(xctx->cairo_ctx); + cairo_rectangle(xctx->cairo_save_ctx, xctx->xrect[0].x, xctx->xrect[0].y, + xctx->xrect[0].width, xctx->xrect[0].height); + cairo_clip(xctx->cairo_save_ctx); + #endif + } else if(what == END) { + for(i=0;igc[i], None); + XSetClipMask(display, xctx->gcstipple[i], None); + } + XSetClipMask(display, xctx->gctiled, None); + #if HAS_CAIRO==1 + cairo_reset_clip(xctx->cairo_ctx); + cairo_reset_clip(xctx->cairo_save_ctx); + #endif + } +} + +/* moved here to avoid Xorg-specific calls in move.c */ +int pending_events(void) +{ + return XPending(display); +} + +void toggle_fullscreen(const char *topwin) +{ + char fullscr[]="add,fullscreen"; + char normal[]="remove,fullscreen"; + unsigned int topwin_id; + Window rootwindow, parent_id; + Window *framewin_child_ptr; + unsigned int framewindow_nchildren; + int fs; + + if(!strcmp(topwin, ".drw")) { + tcleval( "winfo id ."); + sscanf(tclresult(), "0x%x", (unsigned int *) &topwin_id); + } else { + Tcl_VarEval(interp, "winfo id ", xctx->top_path, NULL); + sscanf(tclresult(), "0x%x", (unsigned int *) &topwin_id); + } + XQueryTree(display, topwin_id, &rootwindow, &parent_id, &framewin_child_ptr, &framewindow_nchildren); + fs = tclgetintvar("fullscreen"); + fs = (fs+1)%2; + if(fs==1) tclsetvar("fullscreen","1"); + else if(fs==2) tclsetvar("fullscreen","2"); + else tclsetvar("fullscreen","0"); + + dbg(1, "toggle_fullscreen(): fullscreen=%d\n", fs); + if(fs==2) { + Tcl_VarEval(interp, "pack forget ", xctx->top_path, ".menubar ", xctx->top_path, ".statusbar; update", NULL); + xctx->menu_removed = 1; + } + if(fs !=2 && xctx->menu_removed) { + Tcl_VarEval(interp, "pack ", xctx->top_path, + ".menubar -anchor n -side top -fill x -before ", xctx->top_path, ".drw; pack ", + xctx->top_path, ".statusbar -after ", xctx->top_path, ".drw -anchor sw -fill x; update", NULL); + xctx->menu_removed=0; + } + if(fs == 1) { + window_state(display , parent_id,fullscr); + } else if(fs == 2) { + window_state(display , parent_id,normal); + window_state(display , parent_id,fullscr); + } else { + window_state(display , parent_id,normal); + } + xctx->pending_fullzoom=1; +} + void tclexit(ClientData s) { diff --git a/src/xschem.h b/src/xschem.h index f02a2cf9..a8a81351 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1227,6 +1227,8 @@ extern void toggle_only_probes(); extern void update_symbol(const char *result, int x); extern void tclexit(ClientData s); extern int build_colors(double dim, double dim_bg); /* reparse the TCL 'colors' list and reassign colors 20171113 */ +extern void set_clip_mask(int what); +extern int pending_events(void); extern void drill_hilight(int mode); extern void get_square(double x, double y, int *xx, int *yy); extern void del_wire_table(void);