summaryrefslogtreecommitdiff
path: root/zwgc
diff options
context:
space:
mode:
authorGravatar Karl Ramm <kcr@mit.edu>2009-03-15 22:13:16 +0000
committerGravatar Karl Ramm <kcr@mit.edu>2009-03-15 22:13:16 +0000
commit60cd1ff0635fdeda3c5a2cafee2d9a53f82cae0d (patch)
tree7f8851bf643853330db8bced3cf04e232051a22c /zwgc
parentff385ade8355ce6c685bbabd83c550fbb3c58f82 (diff)
cmu/zwgcplus changes
Diffstat (limited to 'zwgc')
-rw-r--r--zwgc/Makefile.in2
-rw-r--r--zwgc/X_driver.c3
-rw-r--r--zwgc/X_gram.c18
-rw-r--r--zwgc/X_gram.h3
-rw-r--r--zwgc/exec.c10
-rw-r--r--zwgc/main.c184
-rw-r--r--zwgc/mux.c16
-rw-r--r--zwgc/notice.c28
-rw-r--r--zwgc/subscriptions.c16
-rw-r--r--zwgc/xcut.c51
-rw-r--r--zwgc/xshow.c199
-rw-r--r--zwgc/zephyr.c10
12 files changed, 512 insertions, 28 deletions
diff --git a/zwgc/Makefile.in b/zwgc/Makefile.in
index b0f1476..f7b68a8 100644
--- a/zwgc/Makefile.in
+++ b/zwgc/Makefile.in
@@ -40,7 +40,7 @@ OBJS= port_dictionary.o pointer_dictionary.o unsigned_long_dictionary.o \
xcut.o regexp.o character_class.o text_operations.o file.o error.o \
variables.o formatter.o X_fonts.o X_gram.o tty_filter.o \
standard_ports.o xselect.o xmark.o xrevstack.o xerror.o \
- new_string.o new_memory.o
+ new_string.o new_memory.o plus.o
all: zwgc
diff --git a/zwgc/X_driver.c b/zwgc/X_driver.c
index e969eb7..2a71cc2 100644
--- a/zwgc/X_driver.c
+++ b/zwgc/X_driver.c
@@ -224,6 +224,9 @@ static XrmOptionDescRec cmd_options[] = {
{"-foreground", "*foreground", XrmoptionSepArg, (caddr_t) NULL},
{"-geometry", ".geometry", XrmoptionSepArg, (caddr_t) NULL},
{"-iconname", ".iconName", XrmoptionSepArg, (caddr_t) NULL},
+#ifdef CMU_ZWGCPLUS
+ {"-lifespan", "*lifespan", XrmoptionSepArg, (caddr_t) NULL},
+#endif
{"-name", ".name", XrmoptionSepArg, (caddr_t) NULL},
{"-reverse", "*reverseVideo", XrmoptionNoArg, (caddr_t) "on"},
{"-rv", "*reverseVideo", XrmoptionNoArg, (caddr_t) "on"},
diff --git a/zwgc/X_gram.c b/zwgc/X_gram.c
index 6ce4297..712d87a 100644
--- a/zwgc/X_gram.c
+++ b/zwgc/X_gram.c
@@ -34,6 +34,9 @@ static const char rcsid_X_gram_c[] = "$Id$";
#include "xrevstack.h"
#include "xerror.h"
#include "xselect.h"
+#ifdef CMU_ZWGCPLUS
+#include "plus.h"
+#endif
extern XContext desc_context;
extern char *app_instance;
@@ -47,7 +50,7 @@ int internal_border_width = 2;
unsigned long default_fgcolor;
unsigned long default_bgcolor;
unsigned long default_bordercolor;
-long ttl = 500;
+long ttl = 0;
static int reset_saver;
static int border_width = 1;
static int cursor_code = XC_sailboat;
@@ -142,6 +145,16 @@ x_gram_init(Display *dpy)
if (temp && atoi(temp)>=0)
ttl = atoi(temp);
+#ifdef CMU_ZWGCPLUS
+ if (ttl == 0) {
+ temp = get_string_resource("lifespan", "LifeSpan");
+ if (temp && atoi(temp)>=0)
+ ttl = atoi(temp);
+ }
+
+ get_full_names = get_bool_resource("getFullNames", "GetFullNames", 0);
+#endif
+
reverse_stack = get_bool_resource("reverseStack", "ReverseStack", 0);
reset_saver = get_bool_resource("resetSaver", "ResetSaver", 1);
/* The default here should be 1, but mwm sucks */
@@ -222,6 +235,9 @@ x_gram_init(Display *dpy)
xattributes.cursor = cursor;
xattributes.event_mask = (ExposureMask|ButtonReleaseMask|ButtonPressMask
|LeaveWindowMask|Button1MotionMask
+#ifdef CMU_ZWGCPLUS
+ |KeyPressMask
+#endif
|Button3MotionMask|StructureNotifyMask);
xattributes_mask = (CWBackPixel|CWBorderPixel|CWEventMask|CWCursor);
diff --git a/zwgc/X_gram.h b/zwgc/X_gram.h
index ed1adf7..d051f5e 100644
--- a/zwgc/X_gram.h
+++ b/zwgc/X_gram.h
@@ -39,6 +39,9 @@ typedef struct _x_gram {
char *text;
struct _x_gram *below,*above;
Window w;
+#ifdef CMU_ZWGCPLUS
+ char *notice;
+#endif
struct timeval can_die;
} x_gram;
diff --git a/zwgc/exec.c b/zwgc/exec.c
index f24bcb8..9479ed5 100644
--- a/zwgc/exec.c
+++ b/zwgc/exec.c
@@ -453,6 +453,10 @@ void
exec_process_packet(Node *program,
ZNotice_t *notice)
{
+#ifdef CMU_ZWGCPLUS
+ set_stored_notice(notice);
+#endif
+
notice_fields = notice->z_message;
notice_fields_length = notice->z_message_len;
@@ -466,4 +470,10 @@ exec_process_packet(Node *program,
clear_buffer();
(void)exec_subtree(program);
+
+#ifdef CMU_ZWGCPLUS
+ plus_queue_notice(notice);
+ plus_window_deletions(notice); /* OOPS */
+ set_stored_notice(NULL);
+#endif
}
diff --git a/zwgc/main.c b/zwgc/main.c
index 8584eca..3d0fda0 100644
--- a/zwgc/main.c
+++ b/zwgc/main.c
@@ -39,6 +39,13 @@ static const char rcsid_main_c[] = "$Id$";
#include "port.h"
#include "variables.h"
#include "main.h"
+#ifdef CMU_ZCTL_PUNT
+#include "int_dictionary.h"
+#endif
+#ifdef CMU_ZWGCPLUS
+#include "plus.h"
+int zwgcplus = 0;
+#endif
void notice_handler(ZNotice_t *);
static void process_notice(ZNotice_t *, char *);
@@ -48,6 +55,9 @@ static void signal_exit(int);
#ifdef HAVE_ARES
static void notice_callback(void *, int, struct hostent *);
#endif
+#ifdef CMU_ZWGCPLUS
+void reprocess_notice(ZNotice_t *notice, char *hostname);
+#endif
/*
* Global zwgc-wide variables:
@@ -111,32 +121,42 @@ static struct _Node *program = NULL;
static void
fake_startup_packet(void)
{
- ZNotice_t notice;
+ ZNotice_t *notice = (ZNotice_t *)malloc(sizeof(ZNotice_t));
struct timezone tz;
char msgbuf[BUFSIZ];
extern void Z_gettimeofday(struct _ZTimeval *, struct timezone *);
var_set_variable("version", zwgc_version_string);
- (void) memset(&notice, 0, sizeof(notice));
-
- notice.z_version = "";
- notice.z_class = "WG_CTL_CLASS";
- notice.z_class_inst = "WG_CTL_USER<<<>>>";
- notice.z_opcode = "WG_STARTUP";
- notice.z_default_format = "Zwgc mark II version $version now running...\n";
- notice.z_recipient = "";
- notice.z_sender = "ZWGC";
- Z_gettimeofday(&notice.z_time, &tz);
- notice.z_port = 0;
- notice.z_kind = ACKED;
- notice.z_auth = ZAUTH_YES;
+ (void) memset(notice, 0, sizeof(ZNotice_t));
+
+ notice->z_version = "";
+ notice->z_class = "WG_CTL_CLASS";
+ notice->z_class_inst = "WG_CTL_USER<<<>>>";
+ notice->z_opcode = "WG_STARTUP";
+ notice->z_default_format = "Zwgc mark II version $version now running...\n";
+ notice->z_recipient = "";
+ notice->z_sender = "ZWGC";
+ Z_gettimeofday(&notice->z_time, &tz);
+ notice->z_port = 0;
+ notice->z_kind = ACKED;
+ notice->z_auth = ZAUTH_YES;
+ notice->z_charset = ZCHARSET_UNKNOWN;
sprintf(msgbuf,"Zwgc mark II version %s now running...",
zwgc_version_string);
- notice.z_message = msgbuf;
- notice.z_message_len = strlen(notice.z_message)+1;
+ notice->z_message = msgbuf;
+ notice->z_message_len = strlen(notice->z_message)+1;
- process_notice(&notice, NULL);
+#ifdef CMU_ZWGCPLUS
+ list_add_notice(notice);
+ set_notice_fake(notice, 1);
+#endif
+ process_notice(notice, NULL);
+#ifdef CMU_ZWGCPLUS
+ list_del_notice(notice);
+#else
+ free(notice);
+#endif
}
static void
@@ -289,6 +309,9 @@ main(int argc,
* Initialize various subsystems in proper order:
*/
dprintf("Initializing subsystems...\n"); /*<<<>>>*/
+#ifdef CMU_ZWGCPLUS
+ init_noticelist();
+#endif
mux_init();
var_clear_all_variables(); /* <<<>>> */
init_ports(); /* <<<>>> */
@@ -311,6 +334,11 @@ main(int argc,
dprintf("Test Zwgc parser.\n\n");
read_in_description_file();
+#ifdef CMU_ZWGCPLUS
+ if (strcmp(progname, "zwgcplus") == 0)
+ zwgcplus = 1;
+#endif
+
dprintf("Entering main loop\n");
mux_loop();
@@ -329,11 +357,56 @@ main(int argc,
#define USER_SUPPRESS "SUPPRESS"
#define USER_UNSUPPRESS "UNSUPPRESS"
+#ifdef CMU_ZCTL_PUNT
+#define USER_LIST_SUPPRESSED "LIST-SUPPRESSED"
+
+#define PUNT_INC 1024
+extern int_dictionary puntable_addresses_dict;
+ZNotice_t punt_reply;
+
+void
+create_punt_reply(int_dictionary_binding *punt)
+{
+ string binding;
+ int key_len = strlen(punt->key);
+ char *tmp;
+
+ if (!punt_reply.z_message) {
+ punt_reply.z_message = (char *)malloc(PUNT_INC);
+ punt_reply.z_message[0] = 0;
+ }
+
+ if ((punt_reply.z_message_len + key_len + 1) / PUNT_INC >
+ (punt_reply.z_message_len + PUNT_INC - 1) / PUNT_INC) {
+ char *new_message = (char *)malloc((punt_reply.z_message_len
+ / PUNT_INC + 1) * PUNT_INC);
+
+ strcpy(new_message, punt_reply.z_message);
+
+ free(punt_reply.z_message);
+ punt_reply.z_message = new_message;
+ }
+ tmp = punt_reply.z_message + strlen(punt_reply.z_message);
+ strcat (punt_reply.z_message, punt->key);
+ strcat (punt_reply.z_message, "\n");
+ punt_reply.z_message_len += key_len + 1;
+
+ while (*tmp != '\001') tmp++;
+ *tmp = ',';
+ while (*tmp != '\001') tmp++;
+ *tmp = ',';
+}
+#endif /* CMU_ZCTL_PUNT */
+
void
notice_handler(ZNotice_t *notice)
{
struct hostent *fromhost = NULL;
+#if defined(CMU_ZWGCPLUS)
+ list_add_notice(notice);
+#endif
+
if (notice->z_sender_addr.s_addr) {
#ifdef HAVE_ARES
ares_gethostbyaddr(achannel, &(notice->z_sender_addr),
@@ -346,8 +419,12 @@ notice_handler(ZNotice_t *notice)
#endif
}
process_notice(notice, fromhost ? fromhost->h_name : NULL);
+#ifdef CMU_ZWGCPLUS
+ /* Let list_del_notice clean up for us. */
+#else
ZFreeNotice(notice);
free(notice);
+#endif
}
#ifdef HAVE_ARES
@@ -358,9 +435,17 @@ notice_callback(void *arg,
{
ZNotice_t *notice = (ZNotice_t *) arg;
+#ifdef CMU_ZWGCPLUS
+ plus_set_hname(notice, fromhost ? fromhost->h_name : NULL);
+#endif
+
process_notice(notice, fromhost ? fromhost->h_name : NULL);
+#ifdef CMU_ZWGCPLUS
+ list_del_notice(notice);
+#else
ZFreeNotice(notice);
free(notice);
+#endif
}
#endif
@@ -408,12 +493,59 @@ process_notice(ZNotice_t *notice,
free(class);
free(instance);
free(recipient);
+#ifdef CMU_ZCTL_PUNT
+ } else if (!strcasecmp(control_opcode, USER_LIST_SUPPRESSED)) {
+ struct sockaddr_in old, to;
+ int retval;
+
+ if (!notice->z_port) {
+ printf("zwgc: can't reply to LIST-SUPPRESSED request\n");
+ return;
+ }
+ memset((char *) &punt_reply, 0, sizeof(ZNotice_t));
+ punt_reply.z_kind = CLIENTACK;
+ punt_reply.z_class = WG_CTL_CLASS;
+ punt_reply.z_class_inst = "WG_REPLY";
+ punt_reply.z_recipient = "zctl?";
+ punt_reply.z_sender = "Zwgc";
+ punt_reply.z_default_format = "";
+ punt_reply.z_opcode = USER_LIST_SUPPRESSED;
+ punt_reply.z_port = notice->z_port;
+ punt_reply.z_message = NULL;
+ punt_reply.z_message_len = 0;
+
+ if (puntable_addresses_dict) {
+ int_dictionary_Enumerate(puntable_addresses_dict,
+ create_punt_reply);
+ }
+
+ old = ZGetDestAddr();
+ to = old;
+
+ to.sin_port = notice->z_port;
+ if ((retval = ZSetDestAddr(&to)) != ZERR_NONE) {
+ com_err("zwgc",retval,"while setting destination address");
+ exit(1);
+ }
+
+ ZSendNotice(&punt_reply, ZNOAUTH);
+
+ if ((retval = ZSetDestAddr(&old)) != ZERR_NONE) {
+ com_err("zwgc",retval,"while resetting destination address");
+ exit(1);
+ }
+
+ if (punt_reply.z_message) {
+ free(punt_reply.z_message);
+ punt_reply.z_message = NULL;
+ }
+#endif
} else if (!strcasecmp(control_opcode, USER_EXIT)) {
signal_exit(0);
} else
printf("zwgc: unknown control opcode %s.\n", control_opcode);
- return;
+ goto cleanup;
}
if (!zwgc_active) {
@@ -421,7 +553,7 @@ process_notice(ZNotice_t *notice,
if (zwgc_debug)
printf("NON-ACTIVE: PUNTED <%s>!!!!\n", notice->z_class_inst);
#endif
- return;
+ goto cleanup;
}
if (puntable_address_p(notice->z_class,
@@ -431,12 +563,24 @@ process_notice(ZNotice_t *notice,
if (zwgc_debug)
printf("PUNTED <%s>!!!!\n", notice->z_class_inst);
#endif
- return;
+ goto cleanup;
}
exec_process_packet(program, notice);
+ cleanup:
+ return;
}
+#ifdef CMU_ZWGCPLUS
+void reprocess_notice(ZNotice_t *notice,
+ char *hostname)
+{
+ list_add_notice(notice);
+ process_notice(notice, hostname);
+ list_del_notice(notice);
+}
+#endif
+
/***************************************************************************/
/*
diff --git a/zwgc/mux.c b/zwgc/mux.c
index 341e6e6..eb6232f 100644
--- a/zwgc/mux.c
+++ b/zwgc/mux.c
@@ -144,14 +144,24 @@ mux_loop(void)
*/
if (mux_end_loop_p)
break;
-
+ tvp = NULL;
+ tv.tv_sec = 0;
if (have_tty) {
+#ifdef CMU_ZWGCPLUS
+ tv.tv_sec = plus_timequeue_events();
+ if (tv.tv_sec > 10) tv.tv_sec = 10;
+#else
tv.tv_sec = 10;
+#endif
tv.tv_usec = 0;
- tvp = &tv;
+#ifdef CMU_ZWGCPLUS
} else {
- tvp = NULL;
+ tv.tv_sec = plus_timequeue_events();
+ tv.tv_usec = 0;
+#endif
}
+ if (tv.tv_sec)
+ tvp = &tv;
/*
* Do a select on all the file descriptors we care about to
diff --git a/zwgc/notice.c b/zwgc/notice.c
index ca257cd..3ca2dc7 100644
--- a/zwgc/notice.c
+++ b/zwgc/notice.c
@@ -31,6 +31,10 @@ static const char rcsid_notice_c[] = "$Id$";
#include "error.h"
#include "variables.h"
#include "notice.h"
+#ifdef CMU_ZWGCPLUS
+#include <pwd.h>
+#include "plus.h"
+#endif
/*
* int count_nulls(char *data, int length)
@@ -254,6 +258,9 @@ decode_notice(ZNotice_t *notice,
{
char *temp;
string time, notyear, year, date_string, time_string;
+#ifdef CMU_ZWGCPLUS
+ extern char *getSelectedText();
+#endif
/*
* Convert useful notice fields to ascii and store away in
@@ -265,7 +272,7 @@ decode_notice(ZNotice_t *notice,
var_set_variable("instance", notice->z_class_inst);
var_set_variable("opcode", notice->z_opcode);
var_set_variable("default", notice->z_default_format);
- var_set_variable("charset", ZCharsetToString(notice->z_charset));
+ var_set_variable("charset", (char *)ZCharsetToString(notice->z_charset)); /*XXX const*/
var_set_variable("recipient",
(notice->z_recipient[0] ? notice->z_recipient : "*"));
var_set_variable("fullsender", notice->z_sender);
@@ -273,6 +280,14 @@ decode_notice(ZNotice_t *notice,
var_set_variable_then_free_value("kind", z_kind_to_ascii(notice->z_kind));
var_set_variable_then_free_value("auth", z_auth_to_ascii(notice->z_auth));
+#ifdef CMU_ZWGCPLUS
+ if ((temp=getSelectedText()) != 0)
+ var_set_variable("selection", temp);
+
+ var_set_variable("delete_window", "none");
+ var_set_variable("event_time", "none");
+ var_set_variable("event_name", "event");
+#endif
/*
* Set $sender to the name of the notice sender except first strip off the
* realm name if it is the local realm:
@@ -283,6 +298,17 @@ decode_notice(ZNotice_t *notice,
temp-notice->z_sender));
else
var_set_variable("sender", notice->z_sender);
+#ifdef CMU_ZWGCPLUS
+ if (get_full_names) {
+ struct passwd *pwnam = getpwnam(var_get_variable("sender"));
+ if (pwnam) {
+ temp = string_Copy(pwnam->pw_gecos);
+ var_set_variable_then_free_value("sendername", temp);
+ } else {
+ var_set_variable("sendername", "unknown");
+ }
+ }
+#endif
/*
* Convert time & date notice was sent to ascii. The $time
diff --git a/zwgc/subscriptions.c b/zwgc/subscriptions.c
index 5123d5f..198fa7e 100644
--- a/zwgc/subscriptions.c
+++ b/zwgc/subscriptions.c
@@ -42,7 +42,10 @@ static const char rcsid_subscriptions_c[] = "$Id$";
/*
*
*/
-static int_dictionary puntable_addresses_dict = 0;
+#ifndef CMU_ZCTL_PUNT
+static
+#endif
+int_dictionary puntable_addresses_dict = 0;
static void
init_puntable_dict(void)
@@ -62,6 +65,9 @@ address_to_string(string class,
*/
if (string_Eq(recipient,""))
recipient = "*";
+ else if (recipient[0] == '@') {
+ recipient = string_Concat("*", recipient);
+ }
/*
* The following is a hack for now only. It should be replaced with
@@ -81,11 +87,19 @@ int puntable_address_p(string class,
string recipient)
{
string temp;
+ int ret;
if (!puntable_addresses_dict)
init_puntable_dict();
temp = address_to_string(class, instance, recipient);
+ ret = int_dictionary_Lookup(puntable_addresses_dict, temp);
+ free(temp);
+ if (ret)
+ return 1;;
+
+ /* This kludge is to allow punts of wildcard instance to work */
+ temp = address_to_string(class, "*", recipient);
if (int_dictionary_Lookup(puntable_addresses_dict, temp)) {
free(temp);
return(1);
diff --git a/zwgc/xcut.c b/zwgc/xcut.c
index 4fad2a7..22a94c9 100644
--- a/zwgc/xcut.c
+++ b/zwgc/xcut.c
@@ -38,6 +38,9 @@ static const char rcsid_xcut_c[] = "$Id$";
#include "error.h"
#include "xrevstack.h"
#include "X_driver.h"
+#ifdef CMU_ZWGCPLUS
+#include "plus.h"
+#endif
/*
*
@@ -139,7 +142,7 @@ xunmark(Display *dpy,
#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_NUKE 4 /* ctrl */
#define PRESSOP_STOP 5 /* pressop cancelled by moving out of window */
static int current_pressop = PRESSOP_NONE;
@@ -169,8 +172,16 @@ xdestroygram(Display *dpy,
delete_gram(gram);
free(gram->text);
free(gram->blocks);
+#ifdef CMU_ZWGCPLUS
+ if (gram->notice)
+ list_del_notice(gram->notice);
+#endif
free(gram);
+#ifdef CMU_ZWGCPLUS
+ XFlush(dpy);
+#endif
+
if (bottom_gram == NULL && unlinked == NULL) {
/* flush colormap here */
}
@@ -196,6 +207,36 @@ xcut(Display *dpy,
* Dispatch on the event type:
*/
switch(event->type) {
+#ifdef CMU_ZWGCPLUS
+ case KeyPress:
+ {
+ char c;
+ char *plusvar;
+ int res, metaflag;
+ res = XLookupString(event, &c, 1, NULL, NULL);
+ metaflag = event->xkey.state & Mod1Mask;
+
+ /* Recheck if zwgcplus is turned on;
+ * Zephyr variables override zwgc variables
+ */
+
+ zwgcplus = 1;
+ plusvar = (char *)ZGetVariable("zwgcplus") ? (char *)ZGetVariable("zwgcplus") : (char *)var_get_variable("zwgcplus");
+
+ if ((plusvar[0]=='\0') || (strcmp(plusvar,"no") == 0))
+ zwgcplus = 0;
+ else {
+ if (strcmp(plusvar,"no") == 0)
+ zwgcplus = 0;
+ if (strcmp(plusvar,"new") == 0)
+ zwgcplus = 2;
+ }
+
+ if (res != 0 && zwgcplus != 0)
+ plus_retry_notice(gram->notice, c, metaflag);
+ }
+ break;
+#endif
case ClientMessage:
if ((event->xclient.message_type == XA_WM_PROTOCOLS) &&
(event->xclient.format == 32) &&
@@ -273,6 +314,10 @@ xcut(Display *dpy,
selected_text = xmarkGetText();
/* this is ok, since to get here, the selection must be owned */
current_pressop = PRESSOP_EXT;
+#ifdef CMU_ZWGCPLUS
+ if (selected_text)
+ XStoreBytes(dpy, selected_text, strlen(selected_text)+1);
+#endif
}
} else if ( (event->xbutton.state)&ControlMask ) {
current_pressop = PRESSOP_NUKE;
@@ -288,6 +333,10 @@ xcut(Display *dpy,
current_pressop == PRESSOP_EXT) {
if (selected_text) free(selected_text);
selected_text = xmarkGetText();
+#ifdef CMU_ZWGCPLUS
+ if (selected_text)
+ XStoreBytes(dpy, selected_text, strlen(selected_text)+1);
+#endif
} else if (current_pressop == PRESSOP_NUKE) {
XWindowAttributes wa;
int gx,gy;
diff --git a/zwgc/xshow.c b/zwgc/xshow.c
index 6667013..98bab3a 100644
--- a/zwgc/xshow.c
+++ b/zwgc/xshow.c
@@ -34,6 +34,11 @@ static const char rcsid_xshow_c[] = "$Id$";
#include "X_fonts.h"
#include "X_gram.h"
#include "xmode_stack.h"
+#ifdef CMU_ZWGCPLUS
+#include <zephyr/zephyr.h>
+#include "xrevstack.h"
+#include "plus.h"
+#endif
#define max(a,b) ((a)>(b)?(a):(b))
@@ -331,6 +336,9 @@ fixup_and_draw(Display *dpy,
gram_ysize = yofs+internal_border_width;
gram->numblocks = num;
gram->blocks = blocks;
+#ifdef CMU_ZWGCPLUS
+ gram->notice = get_stored_notice();
+#endif
x_gram_create(dpy, gram, gram_xalign, gram_yalign, gram_xpos,
gram_ypos, gram_xsize, gram_ysize, beepcount);
@@ -575,5 +583,196 @@ x_get_input(Display *dpy)
}
}
+#ifdef CMU_ZWGCPLUS
+void
+plus_window_deletions(ZNotice_t *notice)
+{
+ x_gram *tmp, *fry;
+ char *val;
+ int done;
+ static char class_nm[NAMESIZE], instance_nm[NAMESIZE], recip_nm[NAMESIZE];
+
+ if (!dpy)
+ return;
+
+ val = var_get_variable("delete_window");
+
+#ifdef DEBUG_DELETION
+ fprintf(stderr, "delete_window(%s)\n", val);
+#endif
+ if (val) {
+ if (!strcmp(val, "this")) {
+ do {
+ done = 1;
+ tmp = bottom_gram;
+ while (tmp) {
+ if (tmp->notice == (char *)notice) {
+ fry = tmp;
+ tmp = tmp->above;
+ xdestroygram(dpy, fry->w, desc_context, fry, 1);
+ done = 0;
+ } else {
+ tmp = tmp->above;
+ }
+ }
+ } while (!done);
+ }
+ else if (!strcmp(val, "s")) {
+ /* I cheated. This is really sender, not class */
+ strcpy(class_nm, notice->z_sender);
+ do {
+ done = 1;
+ tmp = bottom_gram;
+ while (tmp) {
+ if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_sender, class_nm)) {
+ fry = tmp;
+ tmp = tmp->above;
+ xdestroygram(dpy, fry->w, desc_context, fry, 1);
+ done = 0;
+ } else {
+ tmp = tmp->above;
+ }
+ }
+ } while (!done);
+ }
+ else if (!strcmp(val, "ns")) {
+ /* I cheated. This is really sender, not class */
+ strcpy(class_nm, notice->z_sender);
+ do {
+ done = 1;
+ tmp = bottom_gram;
+ while (tmp) {
+ if (!!strcasecmp(((ZNotice_t *)(tmp->notice))->z_sender, class_nm)) {
+ fry = tmp;
+ tmp = tmp->above;
+ xdestroygram(dpy, fry->w, desc_context, fry, 1);
+ done = 0;
+ } else {
+ tmp = tmp->above;
+ }
+ }
+ } while (!done);
+ }
+ else if (!strcmp(val, "r")) {
+ strcpy(recip_nm, notice->z_recipient);
+ do {
+ done = 1;
+ tmp = bottom_gram;
+ while (tmp) {
+ if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm)) {
+ fry = tmp;
+ tmp = tmp->above;
+ xdestroygram(dpy, fry->w, desc_context, fry, 1);
+ done = 0;
+ } else {
+ tmp = tmp->above;
+ }
+ }
+ } while (!done);
+ }
+ else if (!strcmp(val, "nr")) {
+ strcpy(recip_nm, notice->z_recipient);
+ do {
+ done = 1;
+ tmp = bottom_gram;
+ while (tmp) {
+ if (!!strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm)) {
+ fry = tmp;
+ tmp = tmp->above;
+ xdestroygram(dpy, fry->w, desc_context, fry, 1);
+ done = 0;
+ } else {
+ tmp = tmp->above;
+ }
+ }
+ } while (!done);
+ }
+ else if (!strcmp(val, "cir")) {
+ strcpy(class_nm, notice->z_class);
+ strcpy(instance_nm, notice->z_class_inst);
+ strcpy(recip_nm, notice->z_recipient);
+ do {
+ done = 1;
+ tmp = bottom_gram;
+ while (tmp) {
+ if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_class_inst, instance_nm)
+ && !strcasecmp(((ZNotice_t *)(tmp->notice))->z_class, class_nm)
+ && !strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm))
+ {
+ fry = tmp;
+ tmp = tmp->above;
+ xdestroygram(dpy, fry->w, desc_context, fry, 1);
+ done = 0;
+ } else {
+ tmp = tmp->above;
+ }
+ }
+ } while (!done);
+ }
+ else if (!strcmp(val, "ci")) {
+ strcpy(class_nm, notice->z_class);
+ strcpy(instance_nm, notice->z_class_inst);
+ do {
+ done = 1;
+ tmp = bottom_gram;
+ while (tmp) {
+ if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_class_inst, instance_nm)
+ && !strcasecmp(((ZNotice_t *)(tmp->notice))->z_class, class_nm))
+ {
+ fry = tmp;
+ tmp = tmp->above;
+ xdestroygram(dpy, fry->w, desc_context, fry, 1);
+ done = 0;
+ } else {
+ tmp = tmp->above;
+ }
+ }
+ } while (!done);
+ }
+ else if (!strcmp(val, "cr")) {
+ strcpy(class_nm, notice->z_class);
+ strcpy(recip_nm, notice->z_recipient);
+ do {
+ done = 1;
+ tmp = bottom_gram;
+ while (tmp) {
+ if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_class, class_nm) &&
+ !strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm))
+ {
+ fry = tmp;
+ tmp = tmp->above;
+ xdestroygram(dpy, fry->w, desc_context, fry, 1);
+ done = 0;
+ } else {
+ tmp = tmp->above;
+ }
+ }
+ } while (!done);
+ }
+ else if (!strcmp(val, "c")) {
+ strcpy(class_nm, notice->z_class);
+ do {
+ done = 1;
+ tmp = bottom_gram;
+ while (tmp) {
+ if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_class, class_nm)) {
+ fry = tmp;
+ tmp = tmp->above;
+ xdestroygram(dpy, fry->w, desc_context, fry, 1);
+ done = 0;
+ } else {
+ tmp = tmp->above;
+ }
+ }
+ } while (!done);
+ }
+ else if (!strcmp(val, "all")) {
+ while (bottom_gram) {
+ xdestroygram(dpy, bottom_gram->w, desc_context, bottom_gram, 1);
+ }
+ }
+ }
+}
+#endif
#endif /* X_DISPLAY_MISSING */
diff --git a/zwgc/zephyr.c b/zwgc/zephyr.c
index a2f9751..9c9fbd9 100644
--- a/zwgc/zephyr.c
+++ b/zwgc/zephyr.c
@@ -38,6 +38,9 @@ static const char rcsid_zephyr_c[] = "$Id$";
#ifndef X_DISPLAY_MISSING
#include "X_driver.h"
#endif
+#ifdef CMU_ZWGCPLUS
+#include "plus.h"
+#endif
#ifdef DEBUG
extern int zwgc_debug;
@@ -119,6 +122,13 @@ handle_zephyr_input(void (*notice_handler)(ZNotice_t *))
notice->z_auth = ZCheckAuthentication(notice, &from);
notice_handler(notice);
}
+#ifdef CMU_ZWGCPLUS
+ if (get_list_refcount(notice) <= 0) {
+ /* no windows created */
+ if (!get_notice_fake(notice))
+ list_del_notice(notice);
+ }
+#endif
}
}