2 * XaoS, a fast portable realtime fractal zoomer
3 * Copyright (C) 1996,1997 by
5 * Jan Hubicka (hubicka@paru.cas.cz)
6 * Thomas Marsh (tmarsh@austin.ibm.com)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * Shamelessly ripped for use in xsynaesthesia
26 #ifndef X_DISPLAY_MISSING
33 #include <X11/Xutil.h>
34 #include <X11/cursorfont.h>
46 #define XFlush(x) while(0)
51 #define chkalloc(n) if (!n) fprintf(stderr, "out of memory\n"), exit(-1)
53 int xupdate_size(xdisplay
* d
)
57 int width
= d
->width
, height
= d
->height
;
58 XGetGeometry(d
->display
, d
->window
, &wtmp
, &tmp
, &tmp
, &d
->width
, &d
->height
, (unsigned int *) &tmp
, (unsigned int *) &tmp
);
59 if (d
->width
!= width
|| d
->height
!= height
)
64 void xflip_buffers(xdisplay
* d
)
66 d
->back
= d
->vbuffs
[d
->current
];
68 d
->vbuff
= d
->vbuffs
[d
->current
];
71 void draw_screen(xdisplay
* d
)
73 switch (d
->image
[0]->bits_per_pixel
) {
78 for (s
= (unsigned char *) d
->vbuffs
[d
->current
],
79 e
= (unsigned char *) d
->vbuffs
[d
->current
] + (d
->linewidth
* d
->height
),
80 de
= (unsigned short *) d
->data
[d
->current
]; s
< e
; s
+= 8, de
+= 8)
82 *(de
+ 1) = d
->pixels
[*(s
+ 1)],
83 *(de
+ 2) = d
->pixels
[*(s
+ 2)],
84 *(de
+ 3) = d
->pixels
[*(s
+ 3)],
85 *(de
+ 4) = d
->pixels
[*(s
+ 4)],
86 *(de
+ 5) = d
->pixels
[*(s
+ 5)],
87 *(de
+ 6) = d
->pixels
[*(s
+ 6)],
88 *(de
+ 7) = d
->pixels
[*(s
+ 7)];
91 for (; s
< e
; s
++, de
++)
99 for (s
= (unsigned char *) d
->vbuffs
[d
->current
],
100 e
= (unsigned char *) d
->vbuffs
[d
->current
] + (d
->linewidth
* d
->height
),
101 de
= (unsigned char *) d
->data
[d
->current
]; s
< e
; s
++, de
+=3)
102 de
[0] = d
->pixels
[*s
],
103 de
[1] = d
->pixels
[*s
]>>8,
104 de
[2] = d
->pixels
[*s
]>>16;
112 for (s
= (unsigned char *) d
->vbuffs
[d
->current
],
113 e
= (unsigned char *) d
->vbuffs
[d
->current
] + (d
->linewidth
* d
->height
),
114 de
= (uint32_t *) d
->data
[d
->current
]; s
< e
; s
+= 8, de
+= 8)
116 *(de
+ 1) = d
->pixels
[*(s
+ 1)],
117 *(de
+ 2) = d
->pixels
[*(s
+ 2)],
118 *(de
+ 3) = d
->pixels
[*(s
+ 3)],
119 *(de
+ 4) = d
->pixels
[*(s
+ 4)],
120 *(de
+ 5) = d
->pixels
[*(s
+ 5)],
121 *(de
+ 6) = d
->pixels
[*(s
+ 6)],
122 *(de
+ 7) = d
->pixels
[*(s
+ 7)];
125 for (; s
< e
; s
++, de
++)
131 if (d
->SharedMemFlag
) {
132 XShmPutImage(d
->display
, d
->window
, d
->gc
, d
->image
[d
->current
], 0, 0, 0,
133 0, d
->width
, d
->height
, True
);
138 XPutImage(d
->display
, d
->window
, d
->gc
, d
->image
[d
->current
], 0, 0, 0, 0, d
->width
, d
->height
);
141 d
->screen_changed
= 0;
145 int alloc_shm_image(xdisplay
* new)
148 int temp
, size
= 0, i
;
149 ptr
= DisplayString(new->display
);
150 if (!ptr
|| (*ptr
== ':') || !strncmp(ptr
, "localhost:", 10) ||
151 !strncmp(ptr
, "unix:", 5) || !strncmp(ptr
, "local:", 6)) {
152 new->SharedMemOption
= XQueryExtension(new->display
, "MIT-SHM", &temp
, &temp
, &temp
);
154 new->SharedMemOption
= False
;
157 new->SharedMemFlag
= False
;
159 new->SharedMemOption
= True
;
160 new->SharedMemFlag
= False
;
163 if (new->SharedMemFlag
) {
164 XShmDetach(new->display
, &new->xshminfo
[0]);
165 XShmDetach(new->display
, &new->xshminfo
[1]);
166 new->image
[0]->data
= (char *) NULL
;
167 new->image
[1]->data
= (char *) NULL
;
168 shmdt(new->xshminfo
[0].shmaddr
);
169 shmdt(new->xshminfo
[1].shmaddr
);
171 for (i
= 0; i
< 2; i
++) {
172 if (new->SharedMemOption
) {
176 else if (new->depth
<= 24)
180 new->SharedMemFlag
= False
;
181 new->image
[i
] = XShmCreateImage(new->display
, new->visual
, new->depth
, ZPixmap
,
182 NULL
, &new->xshminfo
[i
], new->width
, new->height
* mul
);
184 temp
= new->image
[i
]->bytes_per_line
* new->image
[i
]->height
;
185 new->linewidth
= new->image
[i
]->bytes_per_line
* 8 / new->image
[i
]->bits_per_pixel
;
188 new->xshminfo
[i
].shmid
= shmget(IPC_PRIVATE
, size
, IPC_CREAT
| 0777);
189 if (new->xshminfo
[i
].shmid
!= -1) {
190 new->xshminfo
[i
].shmaddr
= (char *) shmat(new->xshminfo
[i
].shmid
, 0, 0);
191 if (new->xshminfo
[i
].shmaddr
!= (char *) -1) {
192 new->image
[i
]->data
= new->xshminfo
[i
].shmaddr
;
193 new->data
[i
] = new->vbuffs
[i
] = (char *) new->image
[i
]->data
;
194 new->xshminfo
[i
].readOnly
= True
;
196 new->SharedMemFlag
= XShmAttach(new->display
, &new->xshminfo
[i
]);
197 XSync(new->display
, False
);
198 if (!new->SharedMemFlag
) {
199 XDestroyImage(new->image
[i
]);
200 new->image
[i
] = (XImage
*) NULL
;
201 new->SharedMemFlag
= 0;
205 /* Always Destroy Shared Memory Ident */
206 shmctl(new->xshminfo
[i
].shmid
, IPC_RMID
, 0);
208 if (!new->SharedMemFlag
) {
209 XDestroyImage(new->image
[i
]);
210 new->image
[i
] = (XImage
*) NULL
;
211 new->SharedMemFlag
= 0;
215 new->SharedMemFlag
= 0;
219 new->SharedMemFlag
= 0;
228 void free_shm_image(xdisplay
* d
)
230 if (d
->SharedMemFlag
) {
231 XDestroyImage(d
->image
[0]);
232 XDestroyImage(d
->image
[1]);
233 XShmDetach(d
->display
, &d
->xshminfo
[0]);
234 XShmDetach(d
->display
, &d
->xshminfo
[1]);
235 shmdt(d
->xshminfo
[0].shmaddr
);
236 shmdt(d
->xshminfo
[1].shmaddr
);
242 int alloc_image(xdisplay
* d
)
246 if (!d
->params
->nomitshm
&& alloc_shm_image(d
)) {
248 for (i
= 0; i
< 2; i
++)
249 d
->vbuffs
[i
] = malloc(d
->linewidth
* d
->height
);
254 for (i
= 0; i
< 2; i
++) {
255 d
->image
[i
] = XCreateImage(d
->display
, d
->visual
, d
->depth
, ZPixmap
, 0,
256 NULL
, d
->width
, d
->height
, 8, 0);
257 if (d
->image
[i
] == NULL
) {
258 printf("Out of memory for image..exiting\n");
261 //Add a little extra memory to catch overruns when dumping image to buffer in draw_screen
262 d
->image
[i
]->data
= malloc(d
->image
[i
]->bytes_per_line
* d
->height
+ 32);
263 memset(d
->image
[i
]->data
,0,d
->image
[i
]->bytes_per_line
* d
->height
);
265 if (d
->image
[i
]->data
== NULL
) {
266 printf("Out of memory for image buffers..exiting\n");
269 d
->data
[i
] = d
->vbuffs
[i
] = (char *) d
->image
[i
]->data
;
270 d
->linewidth
= d
->image
[i
]->bytes_per_line
* 8 / d
->image
[i
]->bits_per_pixel
;
273 for (i
= 0; i
< 2; i
++) {
274 //Add a little extra memory to catch overruns
275 //when dumping image to buffer in draw_screen
276 d
->vbuffs
[i
] = malloc(d
->linewidth
* d
->height
+ 32);
277 memset(d
->vbuffs
[i
],0,d
->linewidth
* d
->height
);
279 if (d
->vbuffs
[i
] == NULL
) {
280 printf("Out of memory for image buffers2..exiting\n");
289 void free_image(xdisplay
* d
)
292 free(d
->vbuffs
[0]), free(d
->vbuffs
[1]);
294 if (d
->SharedMemFlag
) {
299 XDestroyImage(d
->image
[0]);
300 XDestroyImage(d
->image
[1]);
302 #define MAX(x,y) ((x)>(y)?(x):(y))
305 xdisplay
*xalloc_display(char *s
, int xHint
, int yHint
, int x
, int y
, xlibparam
* params
)
308 Visual
*defaultvisual
;
312 new = (xdisplay
*) calloc(sizeof(xdisplay
), 1);
314 new->display
= XOpenDisplay((char *) NULL
);
319 new->screen
= DefaultScreen(new->display
);
320 new->attributes
= (XSetWindowAttributes
*)
321 malloc(sizeof(XSetWindowAttributes
));
322 chkalloc(new->attributes
);
323 new->attributes
->background_pixel
= BlackPixel(new->display
,
325 new->attributes
->border_pixel
= BlackPixel(new->display
, new->screen
);
326 new->attributes
->event_mask
= ButtonPressMask
| StructureNotifyMask
| ButtonReleaseMask
| ButtonMotionMask
| KeyPressMask
| ExposureMask
| KeyReleaseMask
;
327 new->attributes
->override_redirect
= False
;
328 new->attr_mask
= CWBackPixel
| CWBorderPixel
| CWEventMask
;
329 new->classX
= InputOutput
;
331 new->parent_window
= RootWindow(new->display
, new->screen
);
332 defaultvisual
= DefaultVisual(new->display
, new->screen
);
333 new->params
= params
;
334 if (!params
->usedefault
) {
335 if (defaultvisual
->class != PseudoColor
|| (!XMatchVisualInfo(new->display
, new->screen
, 8, PseudoColor
, &vis
) && vis
.colormap_size
> 128)) {
336 new->fixedcolormap
= 1;
337 if (!XMatchVisualInfo(new->display
, new->screen
, 15, TrueColor
, &vis
)) {
338 if (!XMatchVisualInfo(new->display
, new->screen
, 16, TrueColor
, &vis
)) {
339 if (!XMatchVisualInfo(new->display
, new->screen
, 32, TrueColor
, &vis
) &&
340 !XMatchVisualInfo(new->display
, new->screen
, 24, TrueColor
, &vis
)) {
341 if (!XMatchVisualInfo(new->display
, new->screen
, 8, PseudoColor
, &vis
) &&
342 !XMatchVisualInfo(new->display
, new->screen
, 7, PseudoColor
, &vis
)) {
343 if (!XMatchVisualInfo(new->display
, new->screen
, 8, TrueColor
, &vis
) &&
344 !XMatchVisualInfo(new->display
, new->screen
, 8, StaticColor
, &vis
) &&
345 !XMatchVisualInfo(new->display
, new->screen
, 8, StaticGray
, &vis
)) {
346 printf("Display does not support PseudoColor depth 7,8,StaticColor depth 8, StaticGray depth 8, Truecolor depth 8,15,16,24 nor 32!\n");
351 new->fixedcolormap
= 0, new->truecolor
= 0;
361 new->depth
= vis
.depth
;
362 new->visual
= vis
.visual
;
363 } else { /*usedefault */
364 vis
.depth
= new->depth
= DefaultDepth(new->display
, new->screen
);
365 new->visual
= defaultvisual
;
366 switch (defaultvisual
->class) {
368 if (new->depth
<= 8) {
371 new->fixedcolormap
= 0;
373 printf("Pseudocolor visual on unsuported depth\n");
381 new->fixedcolormap
= 1;
384 else if (new->depth
<= 16)
386 else if (new->depth
<= 32)
389 printf("Truecolor visual on unsuported depth\n");
394 printf("Unusuported visual\n");
398 /*new->visual->map_entries = 256; */
399 new->colormap
= new->defaultcolormap
= DefaultColormap(new->display
, new->screen
);
401 new->window_name
= s
;
404 new->border_width
= 2;
407 new->font_struct
= (XFontStruct
*) NULL
;
409 new->window
= XCreateWindow(new->display
, new->parent_window
, xHint
, yHint
,
410 new->width
, new->height
, new->border_width
,
411 vis
.depth
, new->classX
, new->visual
,
412 new->attr_mask
, new->attributes
);
413 if (!new->fixedcolormap
&& params
->privatecolormap
) {
414 unsigned long pixels
[256];
416 new->colormap
= XCreateColormap(new->display
, new->window
, new->visual
, AllocNone
);
417 XAllocColorCells(new->display
, new->colormap
, 1, 0, 0, pixels
, MAX(new->visual
->map_entries
, 256));
418 for (i
= 0; i
< 16; i
++) {
419 new->xcolor
.c
[i
].pixel
= pixels
[i
];
421 XQueryColors(new->display
, new->defaultcolormap
, new->xcolor
.c
, 16);
422 XStoreColors(new->display
, new->colormap
, new->xcolor
.c
, 16);
423 new->privatecolormap
= 1;
425 if (!new->fixedcolormap
)
426 XSetWindowColormap(new->display
, new->window
, new->colormap
);
427 new->gc
= XCreateGC(new->display
, new->window
, 0L, &(new->xgcvalues
));
428 XSetBackground(new->display
, new->gc
,
429 BlackPixel(new->display
, new->screen
));
430 XSetForeground(new->display
, new->gc
,
431 WhitePixel(new->display
, new->screen
));
432 XStoreName(new->display
, new->window
, new->window_name
);
433 XMapWindow(new->display
, new->window
);
435 XSelectInput(new->display
, new->window
,
441 StructureNotifyMask
|
442 ButtonPressMask
| ButtonReleaseMask
);
445 new->pixmap
= XCreatePixmap(new->display
, new->window
, new->width
,
446 new->height
, new->depth
);
451 Pixmap p
= XCreatePixmap(new->display
, new->window
, 1,1,1);
452 memset(&c
,0,sizeof(c
));
453 new->cursor
= XCreatePixmapCursor(new->display
, p
,p
,
455 XDefineCursor(new->display
,new->window
,new->cursor
);
456 XFreePixmap(new->display
, p
);
462 void xsetcolor(xdisplay
* d
, int col
)
466 XSetForeground(d
->display
, d
->gc
,
467 BlackPixel(d
->display
, d
->screen
));
470 XSetForeground(d
->display
, d
->gc
,
471 WhitePixel(d
->display
, d
->screen
));
474 if ((col
- 2) > d
->xcolor
.n
) {
475 fprintf(stderr
, "color error\n");
478 XSetForeground(d
->display
, d
->gc
,
479 d
->xcolor
.c
[col
- 2].pixel
);
483 void xrotate_palette(xdisplay
* d
, int direction
, unsigned char co
[3][256], int ncolors
)
487 if (d
->privatecolormap
) {
488 for (i
= 0; i
< d
->xcolor
.n
; i
++) {
489 p
= d
->xcolor
.c
[i
].pixel
;
490 d
->xcolor
.c
[i
].red
= (int) co
[0][p
] * 256;
491 d
->xcolor
.c
[i
].green
= (int) co
[1][p
] * 256;
492 d
->xcolor
.c
[i
].blue
= (int) co
[2][p
] * 256;
494 XStoreColors(d
->display
, d
->colormap
, d
->xcolor
.c
, d
->xcolor
.n
);
497 unsigned long oldpixels
[256];
498 memcpy(oldpixels
, d
->pixels
, sizeof(oldpixels
));
499 p
= (ncolors
- 1 + direction
) % (ncolors
- 1) + 1;
500 for (i
= 1; i
< ncolors
; i
++) { /*this is ugly..I know */
501 d
->pixels
[i
] = oldpixels
[p
];
509 int xalloc_color(xdisplay
* d
, int r
, int g
, int b
, int readwrite
)
512 d
->xcolor
.c
[d
->xcolor
.n
- 1].flags
= DoRed
| DoGreen
| DoBlue
;
513 d
->xcolor
.c
[d
->xcolor
.n
- 1].red
= r
;
514 d
->xcolor
.c
[d
->xcolor
.n
- 1].green
= g
;
515 d
->xcolor
.c
[d
->xcolor
.n
- 1].blue
= b
;
516 d
->xcolor
.c
[d
->xcolor
.n
- 1].pixel
= d
->xcolor
.n
- 1;
517 if ((readwrite
&& !d
->fixedcolormap
) || d
->privatecolormap
) {
519 if (d
->privatecolormap
) {
520 cell
= d
->xcolor
.c
[d
->xcolor
.n
- 1].pixel
+= 16;
521 if (d
->xcolor
.c
[d
->xcolor
.n
- 1].pixel
>= d
->visual
->map_entries
) {
526 if (!XAllocColorCells(d
->display
, d
->colormap
, 0, 0, 0, &cell
, 1)) {
528 if (d
->xcolor
.n
<= 32)
529 printf("Colormap is too full! close some colorfull aplications or use -private\n");
532 d
->xcolor
.c
[d
->xcolor
.n
- 1].pixel
= cell
;
534 XStoreColor(d
->display
, d
->colormap
, &(d
->xcolor
.c
[d
->xcolor
.n
- 1]));
537 if (!XAllocColor(d
->display
, d
->colormap
, &(d
->xcolor
.c
[d
->xcolor
.n
- 1]))) {
539 if (d
->xcolor
.n
<= 32)
540 printf("Colormap is too full! close some colorfull aplications or use -private\n");
543 d
->pixels
[d
->xcolor
.n
- 1] = d
->xcolor
.c
[d
->xcolor
.n
- 1].pixel
;
544 return (d
->depth
!= 8 ? d
->xcolor
.n
- 1 : d
->xcolor
.c
[d
->xcolor
.n
- 1].pixel
);
547 void xfree_colors(xdisplay
* d
)
549 unsigned long pixels
[256];
551 for (i
= 0; i
< d
->xcolor
.n
; i
++)
552 pixels
[i
] = d
->xcolor
.c
[i
].pixel
;
553 if (!d
->privatecolormap
)
554 XFreeColors(d
->display
, d
->colormap
, pixels
, d
->xcolor
.n
, 0);
558 void xfree_display(xdisplay
* d
)
560 XSync(d
->display
, 0);
561 if (d
->font_struct
!= (XFontStruct
*) NULL
) {
562 XFreeFont(d
->display
, d
->font_struct
);
564 XUnmapWindow(d
->display
, d
->window
);
566 XFreePixmap(d
->display
, d
->pixmap
);
568 XDestroyWindow(d
->display
, d
->window
);
569 XFreeCursor(d
->display
, d
->cursor
);
570 XCloseDisplay(d
->display
);
571 free((void *) d
->attributes
);
576 void xline(xdisplay
* d
, int x1
, int y1
, int x2
, int y2
)
578 XDrawLine(d
->display
, d
->pixmap
, d
->gc
, x1
, y1
, x2
, y2
);
579 d
->lastx
= x2
, d
->lasty
= y2
;
580 d
->screen_changed
= 1;
581 } void xlineto(xdisplay
* d
, int x
, int y
)
584 XDrawLine(d
->display
, d
->pixmap
, d
->gc
, d
->lastx
, d
->lasty
, x
, y
);
585 d
->lastx
= x
, d
->lasty
= y
;
586 d
->screen_changed
= 1;
587 } void xrect(xdisplay
* d
, int x1
, int y1
, int x2
, int y2
)
590 XDrawRectangle(d
->display
, d
->pixmap
, d
->gc
, x1
, y1
,
591 (x2
- x1
), (y2
- y1
));
592 d
->lastx
= x2
, d
->lasty
= y2
;
593 d
->screen_changed
= 1;
594 } void xfillrect(xdisplay
* d
, int x1
, int y1
, int x2
, int y2
)
597 XFillRectangle(d
->display
, d
->pixmap
, d
->gc
, x1
, y1
,
598 (x2
- x1
), (y2
- y1
));
599 d
->lastx
= x2
, d
->lasty
= y2
;
600 d
->screen_changed
= 1;
601 } void xpoint(xdisplay
* d
, int x
, int y
)
604 XDrawPoint(d
->display
, d
->pixmap
, d
->gc
, x
, y
);
605 d
->lastx
= x
, d
->lasty
= y
;
606 d
->screen_changed
= 1;
607 } void xflush(xdisplay
* d
)
614 void xclear_screen(xdisplay
* d
)
616 xfillrect(d
, 0, 0, d
->width
, d
->height
);
617 d
->screen_changed
= 1;
621 void xmoveto(xdisplay
* d
, int x
, int y
)
623 d
->lastx
= x
, d
->lasty
= y
;
624 } int xsetfont(xdisplay
* d
, char *font_name
)
627 if (d
->font_struct
!= (XFontStruct
*) NULL
) {
628 XFreeFont(d
->display
, d
->font_struct
);
630 d
->font_struct
= XLoadQueryFont(d
->display
, font_name
);
631 if (!d
->font_struct
) {
632 fprintf(stderr
, "could not load font: %s\n", font_name
);
635 return (d
->font_struct
->max_bounds
.ascent
+ d
->font_struct
->max_bounds
.descent
);
638 void xouttext(xdisplay
* d
, char *string
)
643 XDrawImageString(d
->display
, d
->window
, d
->gc
, d
->lastx
, d
->lasty
,
646 d
->lastx
+= XTextWidth(d
->font_struct
, string
, sz
);
647 d
->screen_changed
= 1;
649 } void xresize(xdisplay
* d
, XEvent
* ev
)
653 XFreePixmap(d
->display
, d
->pixmap
);
655 d
->width
= ev
->xconfigure
.width
;
656 d
->height
= ev
->xconfigure
.height
;
658 d
->pixmap
= XCreatePixmap(d
->display
, d
->window
, d
->width
,
659 d
->height
, d
->depth
);
664 void xarc(xdisplay
* d
, int x
, int y
, unsigned int w
,
665 unsigned int h
, int a1
, int a2
)
667 XDrawArc(d
->display
, d
->pixmap
, d
->gc
, x
, y
, w
, h
, a1
, a2
);
668 } void xfillarc(xdisplay
* d
, int x
, int y
, unsigned int w
,
669 unsigned int h
, int a1
, int a2
)
671 XFillArc(d
->display
, d
->pixmap
, d
->gc
, x
, y
, w
, h
, a1
, a2
);
675 void xsize_set(xdisplay
*d
, int width
, int height
)
677 XResizeWindow(d
->display
, d
->window
, width
, height
);
680 int xmouse_x(xdisplay
* d
)
686 int xmouse_y(xdisplay
* d
)
691 void xmouse_update(xdisplay
* d
)
693 Window rootreturn
, childreturn
;
694 int rootx
= 0, rooty
= 0, buttons
= 0;
698 if (XCheckMaskEvent(d
->display
,ButtonPressMask
| ButtonReleaseMask
, &event
)) {
699 if (event
.type
== ButtonPress
)
700 d
->mouse_buttons
|= 1 << ((XButtonEvent
*)(&event
))->button
;
702 d
->mouse_buttons
&= ~( 1 << ((XButtonEvent
*)(&event
))->button
);
705 XQueryPointer(d
->display
, d
->window
, &rootreturn
, &childreturn
,
706 &rootx
, &rooty
, &(d
->mouse_x
), &(d
->mouse_y
),
710 char xkeyboard_query(xdisplay
* d
) {
713 if (XCheckMaskEvent(d
->display
,KeyPressMask
| KeyReleaseMask
, &event
)) {
715 XKeysymToString(XLookupKeysym((XKeyPressedEvent
*)(&event
),0));
717 if ( ((XKeyPressedEvent
*)(&event
))->state
&
718 (ControlMask
|Mod1Mask
|Mod2Mask
|Mod3Mask
|Mod4Mask
|Mod5Mask
) )
724 if (strlen(str
) == 1)
726 else if (strcmp(str
,"equal") == 0)
728 else if (strcmp(str
,"minus") == 0)
730 else if (strcmp(str
,"bracketleft") == 0)
732 else if (strcmp(str
,"bracketright") == 0)
734 else if (strcmp(str
,"comma") == 0)
736 else if (strcmp(str
,"period") == 0)
738 else if (strcmp(str
,"slash") == 0)
742 if ( ((XKeyPressedEvent
*)(&event
))->state
& ShiftMask
)
744 case '=' : key
= '+'; break;
745 case '[' : key
= '{'; break;
746 case ']' : key
= '}'; break;
747 case ',' : key
= '<'; break;
748 case '/' : key
= '?'; break;
750 if (key
>= 'a' && key
<= 'z')
761 int xsize_update(xdisplay
*d
,int *width
,int *height
) {
764 if (XCheckMaskEvent(d
->display
,StructureNotifyMask
, &event
)) {
765 if (event
.type
== ConfigureNotify
) {
769 *width
= d
->linewidth
;
778 unsigned int xmouse_buttons(xdisplay
* d
)
780 return d
->mouse_buttons
;