60 #include <X11/Xutil.h>
61 #include <X11/cursorfont.h>
73 int last_color_used = 0;
74 int n_colors_used = 0;
105 int p = 0, n = 0, c = 0;
106 unsigned long oldcol;
110 for (subx=0; subx<fbwin->
125 if (n_colors_used == 0) {
129 if (p != last_color_used)
136 oldcol = XGetPixel(xtmp, px, py);
137 if (oldcol != fbwin->
145 XPutPixel(xtmp, px, py, oldcol);
148 XPutPixel(xtmp, px, py, fbwin->
175 if (fbwin->
host_cursor != 0 && n_colors_used < 2) {
184 if (n_colors_used >= 2 && fbwin->
host_cursor == 0) {
315 fatal(
"Using X11 display: %s\n",
335 fatal(
"x11_fb_resize(): win == NULL\n");
343 if (alloc_depth == 24)
345 if (alloc_depth == 15)
352 new_xsize * new_ysize * alloc_depth / 8));
355 memset(win->
ximage_data, 0, new_xsize * new_ysize * alloc_depth / 8);
361 new_xsize, new_ysize, 8, new_xsize * alloc_depth / 8);
365 new_xsize, new_ysize);
378 None, NULL, 0, NULL);
392 size_t alloclen, alloc_depth;
409 memset(fbwin, 0,
sizeof(
struct fb_window));
423 if (display_name != NULL)
424 debug(
"[ x11_fb_init(): framebuffer window %i, %ix%i, DISPLAY"
425 "=%s ]\n",
fb_number, xsize, ysize, display_name);
430 fatal(
"x11_fb_init(\"%s\"): couldn't open display\n", name);
431 if (display_name != NULL)
432 fatal(
"display_name = '%s'\n", display_name);
446 fatal(
"\n***\n*** WARNING! Your X server is running %i-bit "
447 "color mode. This is not really\n",
449 fatal(
"*** supported yet. 8, 15, 16, and 24 bits should "
450 "work.\n*** 24-bit server gives color. Any other bit "
451 "depth gives undefined result!\n***\n\n");
455 debug(
"WARNING! X11 screen depth is not enough for color; "
456 "using only 16 grayscales instead\n");
458 strlcpy(bg,
"Black",
sizeof(bg));
459 strlcpy(fg,
"White",
sizeof(fg));
475 cname[1] = cname[2] = cname[3] =
476 cname[4] = cname[5] = cname[6] =
477 "0123456789ABCDEF"[i];
491 if (alloc_depth == 24)
493 if (alloc_depth == 15)
500 0, CopyFromParent, InputOutput, CopyFromParent, 0,0);
508 StructureNotifyMask | ExposureMask | ButtonPressMask |
509 ButtonReleaseMask | PointerMotionMask | KeyPressMask);
525 alloclen = xsize * ysize * alloc_depth / 8;
530 xsize, ysize, 8, xsize * alloc_depth / 8);
537 debug(
"x11_fb_init(): clearing the XImage\n");
538 for (y=0; y<ysize; y++)
539 for (x=0; x<xsize; x++)
550 for (y=0; y<ysize; y++)
551 for (x=0; x<xsize; x++)
567 static void x11_check_events_machine(
struct emul *
emul,
struct machine *m)
574 int need_redraw = 0, found, i, j;
579 if (event.type==ConfigureNotify) {
583 if (event.type==Expose && event.xexpose.count==0) {
596 if (event.type == MotionNotify) {
621 printf(
"Internal error in x11.c.\n");
630 if (event.type == ButtonPress) {
631 debug(
"[ X11 ButtonPress: %i ]\n",
632 event.xbutton.button);
638 if (event.type == ButtonRelease) {
639 debug(
"[ X11 ButtonRelease: %i ]\n",
640 event.xbutton.button);
646 if (event.type==KeyPress) {
649 XKeyPressedEvent *ke = &
event.xkey;
651 memset(text, 0,
sizeof(text));
653 if (XLookupString(&event.xkey, text,
654 sizeof(text), &key, 0) == 1) {
681 90=Ins(
'0') 91=Del(
',')
821 debug(
"[ unimplemented X11 "
822 "keycode %i ]\n", x);