summaryrefslogtreecommitdiff
path: root/zwgc
diff options
context:
space:
mode:
authorGravatar Marc Horowitz <marc@mit.edu>1989-11-13 19:54:10 +0000
committerGravatar Marc Horowitz <marc@mit.edu>1989-11-13 19:54:10 +0000
commit05bb0c93268b1cc3d18dcbb2757412197983f0a3 (patch)
tree6283f1dbd2bab17688daf7504c6ab83a46c5f162 /zwgc
parent0e01e707e2d0899b98a87625f03699940b32cf96 (diff)
ICCCM reverse stacking implemented
(This is broken until the ICCCM mandates correct reporting of ConfigureNotify events)
Diffstat (limited to 'zwgc')
-rw-r--r--zwgc/X_gram.c115
-rw-r--r--zwgc/X_gram.h6
-rw-r--r--zwgc/xcut.c24
-rw-r--r--zwgc/xrevstack.c56
4 files changed, 111 insertions, 90 deletions
diff --git a/zwgc/X_gram.c b/zwgc/X_gram.c
index 90f85ac..7c89cf8 100644
--- a/zwgc/X_gram.c
+++ b/zwgc/X_gram.c
@@ -13,7 +13,7 @@
*/
#if (!defined(lint) && !defined(SABER))
-static char rcsid_X_gram_c[] = "$Header$";
+static char rcsid_X_gram_c[] = "$Id$";
#endif
#include <zephyr/mit-copyright.h>
@@ -27,14 +27,12 @@ static char rcsid_X_gram_c[] = "$Header$";
#include "X_fonts.h"
#include "error.h"
#include "new_string.h"
+#include "xrevstack.h"
+#include "xerror.h"
extern XContext desc_context;
extern char *app_instance;
-#ifdef REVSTACK
-extern void add_to_bottom();
-#endif
-
/*
*
*/
@@ -51,12 +49,6 @@ static Window group_leader; /* In order to have transient windows,
*/
static XClassHint classhint;
-#ifdef REVSTACK
-int reverse_stack=0;
-extern x_gram *bottom_gram;
-extern Window just_added;
-#endif
-
/* ICCCM note:
*
* the following properties must be set on all top-level windows:
@@ -101,9 +93,7 @@ void x_gram_init(dpy)
XWMHints wmhints;
reverse_video = get_bool_resource("reverseVideo", "ReverseVideo", 0);
-#ifdef REVSTACK
reverse_stack = get_bool_resource("reverseStack", "ReverseStack", 0);
-#endif
temp = get_string_resource("borderWidth", "BorderWidth");
/* <<<>>> */
@@ -202,9 +192,7 @@ void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize)
w = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),xpos,ypos,xsize,
ysize,border_width,foreground_color,
background_color);
-#ifdef REVSTACK
gram->w=w;
-#endif
XDefineCursor(dpy, w, cursor);
@@ -225,66 +213,55 @@ void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize)
XSaveContext(dpy, w, desc_context, (caddr_t)gram);
XSelectInput(dpy, w, ExposureMask|ButtonReleaseMask|ButtonPressMask
|EnterWindowMask|LeaveWindowMask|Button1MotionMask|
- Button3MotionMask|
-#ifdef REVSTACK
- (reverse_stack?StructureNotifyMask:0));
-#else
- 0);
+ Button3MotionMask
+#ifdef notdef
+ |StructureNotifyMask
#endif
+ );
XMapWindow(dpy, w);
-#ifdef REVSTACK
- if (reverse_stack) {
- XWindowChanges winchanges;
- int cfgerr;
- XEvent ev;
- Window bottom_window=(bottom_gram?bottom_gram->w:0);
-
- winchanges.sibling=bottom_window;
- winchanges.stack_mode=bottom_window?Below:Above;
- if ((cfgerr=XConfigureWindow(dpy,w,(bottom_window?CWSibling:0)|
- CWStackMode,&winchanges))>1) {
- /* ICCCM compliance code: This can happen under reparenting
- window managers. This is the compliant code: */
- ev.type=ConfigureRequest;
- ev.xconfigurerequest.parent=RootWindow(dpy,DefaultScreen(dpy));
- ev.xconfigurerequest.window=w;
- ev.xconfigurerequest.above=bottom_window;
- ev.xconfigurerequest.detail=bottom_window?Below:Above;
- ev.xconfigurerequest.value_mask=(bottom_window?CWSibling:0)|
- CWStackMode;
- if ((cfgerr=XSendEvent(dpy,RootWindow(dpy,DefaultScreen(dpy)),False,
- SubstructureRedirectMask|
- SubstructureNotifyMask,&ev))>1)
- /* the event didn't go. Print error, continue */
- ERROR("error configuring window to the bottom of the stack\n");
- }
-
- gram->above = gram;
- gram->below = gram;
- XSync(dpy,False);
- }
-#endif
-
- XFlush(dpy);
-}
+ if (reverse_stack) {
+ if (bottom_gram) {
+ XWindowChanges winchanges;
+
+ winchanges.sibling=bottom_gram->w;
+ winchanges.stack_mode=Below;
+ begin_xerror_trap(dpy);
+ XConfigureWindow(dpy,w,CWSibling|CWStackMode,&winchanges);
+ end_xerror_trap(dpy);
+
+ /* ICCCM compliance code: This will happen under reparenting
+ window managers. This is the compliant code: */
+ if (xerror_happened) {
+ XEvent ev;
+
+ ev.type=ConfigureRequest;
+ ev.xconfigurerequest.parent=DefaultRootWindow(dpy);
+ ev.xconfigurerequest.window=w;
+ ev.xconfigurerequest.above=bottom_gram->w;
+ ev.xconfigurerequest.detail=Below;
+ ev.xconfigurerequest.value_mask=CWSibling|CWStackMode;
+ begin_xerror_trap(dpy);
+ XSendEvent(dpy,RootWindow(dpy,DefaultScreen(dpy)),
+ False,SubstructureRedirectMask|
+ SubstructureNotifyMask,&ev);
+ end_xerror_trap(dpy);
+ if (xerror_happened) {
+ /* the event didn't go. Print error, continue */
+ ERROR("error configuring window to the bottom of the stack\n");
+ }
+ } else {
+ xerror_happened = 0;
+ }
+ }
+ add_to_bottom(gram);
+ if (xerror_happened)
+ pull_to_top(gram);
+ }
-#ifdef notdef
-int intersect(r1x1,r1y1,r1x2,r1y2,r2x1,r2y1,r2x2,r2y2)
-int r1x1,r1y1,r1x2,r1y2,r2x1,r2y1,r2x2,r2y2;
-{
-#define Inside(x,y,x1,y1,x2,y2) ((x>=x1)&&(x<=x2)&&(y>=y1)&&(y<=y2))
- return(Inside(r1x1,r1y1,r2x1,r2y1,r2x2,r2y2) ||
- Inside(r1x1,r1y2,r2x1,r2y1,r2x2,r2y2) ||
- Inside(r1x2,r1y1,r2x1,r2y1,r2x2,r2y2) ||
- Inside(r1x2,r1y2,r2x1,r2y1,r2x2,r2y2) ||
- Inside(r2x1,r2y1,r1x1,r1y1,r1x2,r1y2) ||
- Inside(r2x1,r2y2,r1x1,r1y1,r1x2,r1y2) ||
- Inside(r2x2,r2y1,r1x1,r1y1,r1x2,r1y2) ||
- Inside(r2x2,r2y2,r1x1,r1y1,r1x2,r1y2));
+ XFlush(dpy);
}
-#endif
void x_gram_draw(dpy, w, gram, region)
Display *dpy;
diff --git a/zwgc/X_gram.h b/zwgc/X_gram.h
index 180f471..97388d0 100644
--- a/zwgc/X_gram.h
+++ b/zwgc/X_gram.h
@@ -32,13 +32,11 @@ typedef struct _xblock {
typedef struct _x_gram {
unsigned long bgcolor;
-#ifdef REVSTACK
- struct _x_gram *below,*above;
- Window w;
-#endif
int numblocks;
xblock *blocks;
char *text;
+ struct _x_gram *below,*above;
+ Window w;
} x_gram;
typedef struct _xauxblock {
diff --git a/zwgc/xcut.c b/zwgc/xcut.c
index 184e4b4..8f2d46f 100644
--- a/zwgc/xcut.c
+++ b/zwgc/xcut.c
@@ -34,18 +34,12 @@ static char rcsid_xcut_c[] = "$Id$";
#include "xselect.h"
#include "xmark.h"
#include "error.h"
+#include "xrevstack.h"
/*
*
*/
-#ifdef REVSTACK
-extern void pull_to_top();
-extern void push_to_bottom();
-extern void add_to_bottom();
-extern void unlink_gram();
-#endif
-
extern char *xmarkGetText();
static char *selected_text=NULL;
@@ -209,16 +203,16 @@ void xcut(dpy,event,desc_context)
case ButtonRelease:
if (w == current_window_in && !((event->xbutton.state)&ShiftMask)) {
-#ifdef REVSTACK
- extern int reverse_stack;
-#endif /* REVSTACK */
- if (w == selecting_in) selecting_in = 0;
+ if (w == selecting_in) {
+ selecting_in = 0;
+ xmarkClear();
+ }
+ if (reverse_stack && (gram == bottom_gram))
+ bottom_gram = gram;
XDeleteContext(dpy, w, desc_context);
XDestroyWindow(dpy, w);
-#ifdef REVSTACK
if (reverse_stack)
- unlink_gram(gram);
-#endif
+ delete_gram(gram);
free(gram->text);
free(gram->blocks);
free(gram);
@@ -242,7 +236,7 @@ void xcut(dpy,event,desc_context)
}
break;
-#ifdef REVSTACK
+#ifdef notdef
case ConfigureNotify:
#ifdef DEBUG
if (zwgc_debug)
diff --git a/zwgc/xrevstack.c b/zwgc/xrevstack.c
index af42f53..a18f85c 100644
--- a/zwgc/xrevstack.c
+++ b/zwgc/xrevstack.c
@@ -16,9 +16,61 @@
static char rcsid_xrevstack_c[] = "$Id$";
#endif
-#ifdef REVSTACK
#include <zephyr/mit-copyright.h>
+#define REVSTACK
+
+#ifdef REVSTACK
+#include "X_gram.h"
+#include <stdio.h>
+
+x_gram *bottom_gram = NULL;
+int reverse_stack = 0;
+
+void add_to_bottom(gram)
+ x_gram *gram;
+{
+ if (bottom_gram) {
+ bottom_gram->below = gram;
+ gram->below = NULL;
+ gram->above = bottom_gram;
+ bottom_gram = gram;
+ } else {
+ gram->above = NULL;
+ gram->below = NULL;
+ bottom_gram = gram;
+ }
+}
+
+void pull_to_top(gram)
+ x_gram *gram;
+{}
+
+void push_to_bottom(gram)
+ x_gram *gram;
+{}
+
+void delete_gram(gram)
+ x_gram *gram;
+{
+ if (gram == bottom_gram) {
+ if (gram->above) {
+ bottom_gram = gram->above;
+ bottom_gram->below = NULL;
+ } else {
+ bottom_gram = NULL;
+ }
+ } else {
+ if (gram->above)
+ gram->above->below = gram->below;
+ gram->below->above = gram->above;
+ }
+}
+
+#endif
+
+#ifdef TRUEREVSTACK
+
#include "X_gram.h"
#include "zwgc.h"
#include <stdio.h>
@@ -177,4 +229,4 @@ x_gram *gram;
#endif
}
-#endif /* REVSTACK */
+#endif /* TRUEREVSTACK */