[846] in Zephyr_Bugs
ctrl-right click patch
daemon@ATHENA.MIT.EDU (Yonah Schmeidler)
Tue Feb 4 20:12:19 1997
To: zephyr-bugs@MIT.EDU
Date: Tue, 04 Feb 1997 20:12:13 EST
From: Yonah Schmeidler <yonah@MIT.EDU>
Here's a patch to get neat ctrl-right click behavior from the X driver:
Whenever a zephyr gets displayed, the $X_tag variable is stored for it.
When you ctrl-right click on a zephyr, it then nukes all zephyrs with
the same tag (regardless of their position). Ctrl-left click works the
same as before.
The patch is against the current source in the zephyr locker.
-yonah
*** /mit/zephyr/src/clients/zwgc/X_gram.h Mon Oct 22 02:28:17 1990
--- X_gram.h Tue Feb 4 16:11:28 1997
***************
*** 39,44 ****
--- 39,45 ----
struct _x_gram *below,*above;
Window w;
struct timeval can_die;
+ char *tag;
} x_gram;
typedef struct _xauxblock {
*** /mit/zephyr/src/clients/zwgc/xcut.c Fri Jul 7 18:00:35 1995
--- xcut.c Tue Feb 4 19:54:10 1997
***************
*** 140,147 ****
#define PRESSOP_KILL 1 /* normal click */
#define PRESSOP_SEL 2 /* shift left */
#define PRESSOP_EXT 3 /* shift right */
! #define PRESSOP_NUKE 4 /* ctrl */
! #define PRESSOP_STOP 5 /* pressop cancelled by moving out of window */
static int current_pressop = PRESSOP_NONE;
--- 140,148 ----
#define PRESSOP_KILL 1 /* normal click */
#define PRESSOP_SEL 2 /* shift left */
#define PRESSOP_EXT 3 /* shift right */
! #define PRESSOP_NUKE 4 /* ctrl left */
! #define PRESSOP_TNUK 5 /* ctrl right */
! #define PRESSOP_STOP 6 /* pressop cancelled by moving out of window */
static int current_pressop = PRESSOP_NONE;
***************
*** 170,175 ****
--- 171,177 ----
delete_gram(gram);
free(gram->text);
free(gram->blocks);
+ free(gram->tag);
free(gram);
if (bottom_gram == NULL && unlinked == NULL) {
***************
*** 222,228 ****
case LeaveNotify:
if (current_pressop == PRESSOP_KILL ||
! current_pressop == PRESSOP_NUKE)
current_pressop = PRESSOP_STOP;
break;
--- 224,231 ----
case LeaveNotify:
if (current_pressop == PRESSOP_KILL ||
! current_pressop == PRESSOP_NUKE ||
! current_pressop == PRESSOP_TNUK)
current_pressop = PRESSOP_STOP;
break;
***************
*** 271,277 ****
current_pressop = PRESSOP_EXT;
}
} else if ( (event->xbutton.state)&ControlMask ) {
! current_pressop = PRESSOP_NUKE;
} else {
current_pressop = PRESSOP_KILL;
}
--- 274,283 ----
current_pressop = PRESSOP_EXT;
}
} else if ( (event->xbutton.state)&ControlMask ) {
! if (event->xbutton.button==Button1)
! current_pressop = PRESSOP_NUKE;
! else if (event->xbutton.button==Button3)
! current_pressop = PRESSOP_TNUK;
} else {
current_pressop = PRESSOP_KILL;
}
***************
*** 320,325 ****
--- 326,351 ----
xdestroygram(dpy,gram->w,desc_context,gram);
}
}
+ } else if (current_pressop == PRESSOP_TNUK) {
+ XWindowAttributes wa;
+ x_gram *next, *our_gram = gram;
+ char *tag = gram->tag;
+
+ for (gram = bottom_gram ; gram ; gram = next) {
+ next = gram->above;
+
+ if (gram == our_gram)
+ continue;
+
+ XGetWindowAttributes(dpy,gram->w,&wa);
+
+ if ((wa.map_state == IsViewable) &&
+ ((tag == gram->tag) ||
+ (tag && gram->tag && !strcmp(tag, gram->tag))))
+ xdestroygram(dpy,gram->w,desc_context,gram);
+ }
+
+ xdestroygram(dpy,our_gram->w,desc_context,our_gram);
}
current_pressop = PRESSOP_NONE;
break;
*** /mit/zephyr/src/clients/zwgc/xshow.c Fri Jul 7 18:00:50 1995
--- xshow.c Tue Feb 4 16:21:20 1997
***************
*** 143,149 ****
int lofs, cofs, rofs;
int ystart,yend;
! char *bgstr, *geometry, xpos[10], ypos[10], xfrom, yfrom;
gram = (x_gram *)malloc(sizeof(x_gram));
--- 143,149 ----
int lofs, cofs, rofs;
int ystart,yend;
! char *bgstr, *geometry, xpos[10], ypos[10], xfrom, yfrom, *tag;
gram = (x_gram *)malloc(sizeof(x_gram));
***************
*** 327,333 ****
if (bgstr && bgstr[0])
gram->bgcolor = x_string_to_color(bgstr,default_bgcolor);
!
gram_xsize = maxwidth+(internal_border_width<<1);
gram_ysize = yofs+internal_border_width;
gram->numblocks = num;
--- 327,340 ----
if (bgstr && bgstr[0])
gram->bgcolor = x_string_to_color(bgstr,default_bgcolor);
! if ((tag = var_get_variable("X_tag")),(tag[0]=='\0'))
! gram->tag = 0;
! else
! {
! if ((gram->tag = malloc(strlen(tag)+1)) != 0)
! strcpy(gram->tag, tag);
! }
!
gram_xsize = maxwidth+(internal_border_width<<1);
gram_ysize = yofs+internal_border_width;
gram->numblocks = num;