Subject:
Re: Microwindows 0.87pre3 released
From:
Daniel R Risacher ####@####.####
Date:
20 Dec 1999 05:29:37 -0000
Message-Id: <m266xunq3f.fsf@risacher.ebicom.net>
Sigh.
I was working on NanoX tonight as well, but unfortunately against
87pre2, so the diff will probably not apply against 87pre3 (which I
haven't looked at yet.)
Anyhow, as further prep work for nanox windowmanager support, I
implemented GrReparentWindow(). This includes changes to the move.c
demo to demonstrate and test the capability.
I also fixed a moderately serious bug in GrGetWindowInfo() that would
cause a server crash when called on any window without children and
siblings.
Finally, I just noticed that
#define GR_EVENT_TYPE_ERROR ((GR_EVENT_TYPE) -1)
but
#define GR_EVENTMASK(n) (((GR_EVENT_MASK) 1) << (n))
and
#define GR_EVENT_MASK_ERROR GR_EVENTMASK(GR_EVENT_TYPE_ERROR)
Which I think means that GR_EVENT_MASK_ERROR is always zero. Is this
what was intended?
Sleepily,
Daniel
Here's the patch, against 0.87pre2:
diff -u -w -r src.old/demos/nanox/move.c src/demos/nanox/move.c
--- src.old/demos/nanox/move.c Tue Dec 14 00:23:38 1999
+++ src/demos/nanox/move.c Sun Dec 19 22:52:34 1999
@@ -22,7 +22,7 @@
window2 = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 100, 100, 60, 4, BLACK, BLUE);
subwindow2 = GrNewWindow(window2, 5, 5, 90, 50, 4, WHITE, RED);
- subsubwin2 = GrNewWindow(subwindow2, 10, 10, 10, 10, 2, GREEN, BLUE);
+/* subsubwin2 = GrNewWindow(subwindow2, 10, 10, 10, 10, 2, GREEN, BLUE); */
GrSelectEvents(window1,
GR_EVENT_MASK_EXPOSURE |
@@ -42,6 +42,10 @@
GR_EVENT_MASK_MOUSE_MOTION |
0);
+ GrSelectEvents(subsubwin1,
+ GR_EVENT_MASK_BUTTON_DOWN |
+ 0);
+
GrMapWindow(subsubwin1);
GrMapWindow(subwindow1);
GrMapWindow(window1);
@@ -57,18 +61,33 @@
case GR_EVENT_TYPE_NONE:
break;
case GR_EVENT_TYPE_BUTTON_DOWN:
- if (event.button.changebuttons & GR_BUTTON_L) {
offset_x = event.button.x;
offset_y = event.button.y;
- }
+
if (event.button.changebuttons & GR_BUTTON_R) {
GrRaiseWindow(event.button.wid);
}
+ if (event.button.wid == subsubwin1) {
+ GR_WINDOW_INFO winfo;
+ GrGetWindowInfo(subsubwin1, &winfo);
+ if (winfo.parent == subwindow1) {
+ GrReparentWindow(subsubwin1, subwindow2, 10, 10);
+ } else {
+ GrReparentWindow(subsubwin1, subwindow1, 10, 10);
+ }
+ }
case GR_EVENT_TYPE_MOUSE_MOTION:
- if (event.mouse.buttons == GR_BUTTON_L)
+ if (event.mouse.buttons == GR_BUTTON_L &&
+ (event.mouse.wid == window1 || event.mouse.wid == window2)) {
GrMoveWindow(event.mouse.wid,
event.mouse.rootx - offset_x,
event.mouse.rooty - offset_y);
+ }
+ if (event.mouse.buttons == GR_BUTTON_R) {
+ GrResizeWindow(event.mouse.wid,
+ event.mouse.x + 1,
+ event.mouse.y + 1);
+ }
break;
case GR_EVENT_TYPE_EXPOSURE:
//GrFillRect(event.exposure.wid, defgc,
diff -u -w -r src.old/nano-X.h src/nano-X.h
--- src.old/nano-X.h Thu Dec 2 01:58:09 1999
+++ src/nano-X.h Sun Dec 19 23:02:49 1999
@@ -164,6 +164,7 @@
#define GR_EVENT_MASK_KEY_UP GR_EVENTMASK(GR_EVENT_TYPE_KEY_UP)
#define GR_EVENT_MASK_FOCUS_IN GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_IN)
#define GR_EVENT_MASK_FOCUS_OUT GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_OUT)
+#define GR_EVENT_MASK_FDINPUT GR_EVENTMASK(GR_EVENT_TYPE_FDINPUT)
#define GR_EVENT_MASK_ALL ((GR_EVENT_MASK) -1L)
/* Modifiers generated by special keyboard shift-like keys.
@@ -172,7 +173,7 @@
*/
#define GR_MODIFIER_SHIFT ((MODIFIER) 0x01) /* shift */
#define GR_MODIFIER_CTRL ((MODIFIER) 0x02) /* control */
-#define GR_MODIFIER_META ((MODIFIER) 0x03) /* meta or alt */
+#define GR_MODIFIER_META ((MODIFIER) 0x04) /* meta or alt */
#define GR_MODIFIER_ANY ((MODIFIER) 0x07) /* any modifier */
/* Button flags. */
@@ -297,6 +298,7 @@
void GrLowerWindow(GR_WINDOW_ID wid);
void GrMoveWindow(GR_WINDOW_ID wid, GR_COORD x, GR_COORD y);
void GrResizeWindow(GR_WINDOW_ID wid, GR_SIZE width, GR_SIZE height);
+void GrReparentWindow(GR_WINDOW_ID wid, GR_WINDOW_ID pwid, GR_COORD x, GR_COORD y);
void GrGetWindowInfo(GR_WINDOW_ID wid, GR_WINDOW_INFO *infoptr);
void GrGetFontInfo(GR_FONT font, GR_FONT_INFO *fip);
void GrSetFocus(GR_WINDOW_ID wid);
diff -u -w -r src.old/nanox/client.c src/nanox/client.c
--- src.old/nanox/client.c Thu Dec 2 01:52:03 1999
+++ src/nanox/client.c Sun Dec 19 21:24:55 1999
@@ -631,6 +631,21 @@
}
/*
+ * Reparent the window to be the specified size.
+ */
+void
+GrReparentWindow(GR_WINDOW_ID wid, GR_WINDOW_ID pwid, GR_COORD x, GR_COORD y)
+{
+ nxReparentWindowReq *req;
+
+ req = AllocReq(ReparentWindow);
+ req->windowid = wid;
+ req->parentid = pwid;
+ req->x = x;
+ req->y = y;
+}
+
+/*
* Clear the specified window by setting it to its background color.
* If the exposeflag is nonzero, then this also creates an exposure
* event for the window.
diff -u -w -r src.old/nanox/nxproto.h src/nanox/nxproto.h
--- src.old/nanox/nxproto.h Wed Dec 1 20:52:20 1999
+++ src/nanox/nxproto.h Sun Dec 19 18:53:18 1999
@@ -519,4 +519,15 @@
UINT32 color;
} nxFindColorReq;
-#define GrTotalNumCalls 47
+#define GrNumReparentWindow 47
+typedef struct {
+ BYTE8 reqType;
+ BYTE8 hilength;
+ UINT16 length;
+ UINT32 windowid;
+ UINT32 parentid;
+ INT16 x;
+ INT16 y;
+} nxReparentWindowReq;
+
+#define GrTotalNumCalls 48
diff -u -w -r src.old/nanox/serv.h src/nanox/serv.h
--- src.old/nanox/serv.h Thu Dec 2 00:49:38 1999
+++ src/nanox/serv.h Sun Dec 19 21:26:21 1999
@@ -210,6 +210,7 @@
void GrLowerWindowWrapper(void *);
void GrMoveWindowWrapper(void *);
void GrResizeWindowWrapper(void *);
+void GrReparentWindowWrapper(void *);
void GrGetWindowInfoWrapper(void *);
void GrGetFontInfoWrapper(void *);
void GrSetFocusWrapper(void *);
diff -u -w -r src.old/nanox/srvfunc.c src/nanox/srvfunc.c
--- src.old/nanox/srvfunc.c Tue Dec 14 00:54:18 1999
+++ src/nanox/srvfunc.c Sun Dec 19 22:51:13 1999
@@ -166,9 +166,9 @@
}
infoptr->wid = wid;
- infoptr->parent = wp->parent->id;
- infoptr->child = wp->children->id;
- infoptr->sibling = wp->siblings->id;
+ infoptr->parent = wp->parent?wp->parent->id:0;
+ infoptr->child = wp->children?wp->children->id:0;
+ infoptr->sibling = wp->siblings?wp->siblings->id:0;
infoptr->mapped = wp->mapped;
infoptr->unmapcount = wp->unmapcount;
infoptr->inputonly = !wp->output;
@@ -394,6 +394,50 @@
GsWpUnmapWindow(wp);
wp->width = width;
wp->height = height;
+ GsWpMapWindow(wp);
+}
+
+/*
+ * Move the window to the specified position relative to its parent.
+ */
+void
+GrReparentWindow(GR_WINDOW_ID wid, GR_WINDOW_ID pwid, GR_COORD x, GR_COORD y)
+{
+ GR_WINDOW *wp; /* window structure */
+ GR_WINDOW *pwp; /* parent window structure */
+ GR_WINDOW **mysibptr; /* handle to my sibling ptr */
+ GR_COORD offx, offy;
+
+ wp = GsFindWindow(wid);
+ pwp = GsFindWindow(pwid);
+ if (wp == NULL || pwp == NULL)
+ return;
+ if (wp == rootwp) {
+ GsError(GR_ERROR_ILLEGAL_ON_ROOT_WINDOW, wid);
+ return;
+ }
+
+ x += pwp->x;
+ y += pwp->y;
+ offx = x - wp->x;
+ offy = y - wp->y;
+
+ if (wp->x == x && wp->y == y)
+ return;
+
+ /*
+ * This should be optimized to not require redrawing of the window
+ * when possible.
+ */
+ GsWpUnmapWindow(wp);
+ for (mysibptr = &(wp->parent->children);
+ *mysibptr != wp;
+ mysibptr = &((*mysibptr)->siblings));
+ *mysibptr = wp->siblings;
+ wp->parent = pwp;
+ wp->siblings = pwp->children;
+ pwp->children = wp;
+ OffsetWindow(wp, offx, offy);
GsWpMapWindow(wp);
}
diff -u -w -r src.old/nanox/srvnet.c src/nanox/srvnet.c
--- src.old/nanox/srvnet.c Thu Dec 2 01:49:03 1999
+++ src/nanox/srvnet.c Sun Dec 19 22:19:15 1999
@@ -169,6 +169,14 @@
}
void
+GrReparentWindowWrapper(void *r)
+{
+ nxReparentWindowReq *req = r;
+
+ GrReparentWindow(req->windowid, req->parentid, req->x, req->y);
+}
+
+void
GrGetWindowInfoWrapper(void *r)
{
nxGetWindowInfoReq *req = r;
@@ -543,7 +551,8 @@
{GrSetCursorWrapper, "GrSetCursor"},
{GrMoveCursorWrapper, "GrMoveCursor"},
{GrGetSystemPaletteWrapper, "GrGetSystemPalette"},
- {GrFindColorWrapper, "GrFindColor"}
+ {GrFindColorWrapper, "GrFindColor"},
+ {GrReparentWindowWrapper, "GrReparentWindow"}
};
/*