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);
387 struct fb_window *
x11_fb_init(
int xsize,
int ysize,
char *name,
392 size_t alloclen, alloc_depth;
394 struct fb_window *fbwin;
405 (
struct fb_window *) malloc(
sizeof(
struct fb_window)));
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);
427 x11_display = XOpenDisplay(display_name);
429 if (x11_display == NULL) {
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);
437 DefaultScreen(x11_display);
439 DefaultDepth(x11_display,
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));
461 XParseColor(x11_display, DefaultColormap(x11_display,
463 XAllocColor(x11_display, DefaultColormap(x11_display,
466 XParseColor(x11_display, DefaultColormap(x11_display,
468 XAllocColor(x11_display, DefaultColormap(x11_display,
475 cname[1] = cname[2] = cname[3] =
476 cname[4] = cname[5] = cname[6] =
477 "0123456789ABCDEF"[i];
479 XParseColor(x11_display, DefaultColormap(x11_display,
482 XAllocColor(x11_display, DefaultColormap(x11_display,
491 if (alloc_depth == 24)
493 if (alloc_depth == 15)
497 x11_display, DefaultRootWindow(x11_display),
500 0, CopyFromParent, InputOutput, CopyFromParent, 0,0);
506 XSelectInput(x11_display,
508 StructureNotifyMask | ExposureMask | ButtonPressMask |
509 ButtonReleaseMask | PointerMotionMask | KeyPressMask);
510 fbwin->
x11_fb_gc = XCreateGC(x11_display,
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);
844 x11_check_events_machine(emul, emul->
machines[i]);
#define CURSOR_COLOR_INVERT
void fatal(const char *fmt,...)
#define CURSOR_COLOR_TRANSPARENT
void x11_check_event(struct emul *emul)
XColor x11_graycolor[N_GRAYCOLORS]
int current_display_name_nr
void x11_init(struct machine *machine)
void x11_putimage_fb(struct machine *, int)
void console_makeavail(int handle, char ch)
void x11_redraw(struct machine *m, int x)
void console_mouse_coordinates(int x, int y, int fb_nr)
Pixmap host_cursor_pixmap
struct fb_window * x11_fb_init(int xsize, int ysize, char *name, int scaledown, struct machine *machine)
void console_mouse_button(int button, int pressed)
#define CHECK_ALLOCATION(ptr)
void x11_redraw_cursor(struct machine *m, int i)
void x11_putpixel_fb(struct machine *m, int fb, int x, int y, int color)
void x11_fb_resize(struct fb_window *win, int new_xsize, int new_ysize)
void x11_set_standard_properties(struct fb_window *fb_window, char *name)
unsigned char * ximage_data
struct fb_window ** fb_windows
struct machine ** machines
int cursor_pixels[CURSOR_MAXY][CURSOR_MAXX]