aboutsummaryrefslogtreecommitdiff
path: root/src/libdraw/x11-init.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2003-11-23 18:15:43 +0000
committerrsc <devnull@localhost>2003-11-23 18:15:43 +0000
commit16a709666981e77a00a88a87b286b586ac77ffdc (patch)
tree7320f931d0cdfcb86fe07dba025b489e66ed5648 /src/libdraw/x11-init.c
parent986b36bccd134726eea42f2cfabff2943d729ac4 (diff)
downloadplan9port-16a709666981e77a00a88a87b286b586ac77ffdc.tar.gz
plan9port-16a709666981e77a00a88a87b286b586ac77ffdc.tar.bz2
plan9port-16a709666981e77a00a88a87b286b586ac77ffdc.zip
Add drawsetlabel(Display*, char*).
Turn window destruction into "hangup" note. Fix (?) snarf buffer management. Add latin1 keyboard translation.
Diffstat (limited to 'src/libdraw/x11-init.c')
-rw-r--r--src/libdraw/x11-init.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/libdraw/x11-init.c b/src/libdraw/x11-init.c
index 28f6ae40..e402dee2 100644
--- a/src/libdraw/x11-init.c
+++ b/src/libdraw/x11-init.c
@@ -100,6 +100,8 @@ getwindow(Display *d, int ref)
{
Image *i;
+ if(_x.destroyed)
+ postnote(PNGROUP, getpgrp(), "hangup");
if(xreplacescreenimage() == 0)
return 0;
freeimage(d->screenimage);
@@ -124,7 +126,7 @@ static int
xioerror(XDisplay *d)
{
print("X I/O error\n");
- exit(1);
+ abort();
return -1;
}
@@ -365,6 +367,11 @@ xattach(char *label)
XFlush(_x.display);
/*
+ * Look up clipboard atom.
+ */
+ _x.clipboard = XInternAtom(_x.display, "CLIPBOARD", True);
+
+ /*
* Lots of display connections for various procs.
*/
_x.kbdcon = XOpenDisplay(NULL);
@@ -388,6 +395,46 @@ fprint(2, "%r\n");
return nil;
}
+int
+drawsetlabel(Display *d, char *label)
+{
+ char *argv[2];
+ XClassHint classhint;
+ XTextProperty name;
+
+ /*
+ * Label and other properties required by ICCCCM.
+ */
+ memset(&name, 0, sizeof name);
+ if(label == nil)
+ label = "pjw-face-here";
+ name.value = (uchar*)label;
+ name.encoding = XA_STRING;
+ name.format = 8;
+ name.nitems = strlen(name.value);
+
+ memset(&classhint, 0, sizeof classhint);
+ classhint.res_name = label;
+ classhint.res_class = label;
+
+ argv[0] = label;
+ argv[1] = nil;
+
+ XSetWMProperties(
+ _x.display, /* display */
+ _x.drawable, /* window */
+ &name, /* XA_WM_NAME property */
+ &name, /* XA_WM_ICON_NAME property */
+ argv, /* XA_WM_COMMAND */
+ 1, /* argc */
+ nil, /* XA_WM_NORMAL_HINTS */
+ nil, /* XA_WM_HINTS */
+ &classhint /* XA_WM_CLASSHINTS */
+ );
+ XFlush(_x.display);
+ return 0;
+}
+
/*
* Create a GC with a particular fill style and XXX.
* Disable generation of GraphicsExpose/NoExpose events in the GC.
@@ -604,6 +651,19 @@ xexpose(XEvent *e, XDisplay *xd)
}
int
+xdestroy(XEvent *e, XDisplay *xd)
+{
+ XDestroyWindowEvent *xe;
+
+ xe = (XDestroyWindowEvent*)e;
+ if(xe->window == _x.drawable){
+ _x.destroyed = 1;
+ return 1;
+ }
+ return 0;
+}
+
+int
xconfigure(XEvent *e, XDisplay *xd)
{
Rectangle r;