You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

626 lines
21 KiB

  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the Do What The Fuck You Want To
  10. * Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. /*
  14. * This file contains the libcaca X11 input and output driver
  15. */
  16. #include "config.h"
  17. #include "common.h"
  18. #if defined(USE_X11)
  19. #include <X11/Xlib.h>
  20. #include <X11/Xutil.h>
  21. #include <X11/keysym.h>
  22. #if defined(HAVE_X11_XKBLIB_H)
  23. # include <X11/XKBlib.h>
  24. #endif
  25. #include <stdio.h> /* BUFSIZ */
  26. #include <stdlib.h>
  27. #include "caca.h"
  28. #include "caca_internals.h"
  29. #include "cucul.h"
  30. #include "cucul_internals.h"
  31. /*
  32. * Local functions
  33. */
  34. static int x11_error_handler(Display *, XErrorEvent *);
  35. struct driver_private
  36. {
  37. Display *dpy;
  38. Window window;
  39. Pixmap pixmap;
  40. GC gc;
  41. long int event_mask;
  42. int font_width, font_height;
  43. int colors[4096];
  44. Font font;
  45. XFontStruct *font_struct;
  46. int font_offset;
  47. Cursor pointer;
  48. Atom wm_protocols;
  49. Atom wm_delete_window;
  50. #if defined(HAVE_X11_XKBLIB_H)
  51. Bool autorepeat;
  52. #endif
  53. };
  54. static int x11_init_graphics(caca_display_t *dp)
  55. {
  56. Colormap colormap;
  57. XSetWindowAttributes x11_winattr;
  58. int (*old_error_handler)(Display *, XErrorEvent *);
  59. char const *fonts[] = { NULL, "8x13bold", "fixed" }, **parser;
  60. char const *geometry;
  61. unsigned int width = 0, height = 0;
  62. int i;
  63. dp->drv.p = malloc(sizeof(struct driver_private));
  64. #if defined(HAVE_GETENV)
  65. geometry = getenv("CACA_GEOMETRY");
  66. if(geometry && *geometry)
  67. sscanf(geometry, "%ux%u", &width, &height);
  68. #endif
  69. if(width && height)
  70. _cucul_set_canvas_size(dp->cv, width, height);
  71. dp->drv.p->dpy = XOpenDisplay(NULL);
  72. if(dp->drv.p->dpy == NULL)
  73. return -1;
  74. #if defined(HAVE_GETENV)
  75. fonts[0] = getenv("CACA_FONT");
  76. if(fonts[0] && *fonts[0])
  77. parser = fonts;
  78. else
  79. #endif
  80. parser = fonts + 1;
  81. /* Ignore font errors */
  82. old_error_handler = XSetErrorHandler(x11_error_handler);
  83. /* Parse our font list */
  84. for( ; ; parser++)
  85. {
  86. if(!*parser)
  87. {
  88. XSetErrorHandler(old_error_handler);
  89. XCloseDisplay(dp->drv.p->dpy);
  90. return -1;
  91. }
  92. dp->drv.p->font = XLoadFont(dp->drv.p->dpy, *parser);
  93. if(!dp->drv.p->font)
  94. continue;
  95. dp->drv.p->font_struct = XQueryFont(dp->drv.p->dpy, dp->drv.p->font);
  96. if(!dp->drv.p->font_struct)
  97. {
  98. XUnloadFont(dp->drv.p->dpy, dp->drv.p->font);
  99. continue;
  100. }
  101. break;
  102. }
  103. /* Reset the default X11 error handler */
  104. XSetErrorHandler(old_error_handler);
  105. dp->drv.p->font_width = dp->drv.p->font_struct->max_bounds.width;
  106. dp->drv.p->font_height = dp->drv.p->font_struct->max_bounds.ascent
  107. + dp->drv.p->font_struct->max_bounds.descent;
  108. dp->drv.p->font_offset = dp->drv.p->font_struct->max_bounds.descent;
  109. colormap = DefaultColormap(dp->drv.p->dpy, DefaultScreen(dp->drv.p->dpy));
  110. for(i = 0x000; i < 0x1000; i++)
  111. {
  112. XColor color;
  113. color.red = ((i & 0xf00) >> 8) * 0x1111;
  114. color.green = ((i & 0x0f0) >> 4) * 0x1111;
  115. color.blue = (i & 0x00f) * 0x1111;
  116. XAllocColor(dp->drv.p->dpy, colormap, &color);
  117. dp->drv.p->colors[i] = color.pixel;
  118. }
  119. x11_winattr.backing_store = Always;
  120. x11_winattr.background_pixel = dp->drv.p->colors[0x000];
  121. x11_winattr.event_mask = ExposureMask | StructureNotifyMask;
  122. dp->drv.p->window =
  123. XCreateWindow(dp->drv.p->dpy, DefaultRootWindow(dp->drv.p->dpy), 0, 0,
  124. dp->cv->width * dp->drv.p->font_width,
  125. dp->cv->height * dp->drv.p->font_height,
  126. 0, 0, InputOutput, 0,
  127. CWBackingStore | CWBackPixel | CWEventMask,
  128. &x11_winattr);
  129. dp->drv.p->wm_protocols =
  130. XInternAtom(dp->drv.p->dpy, "WM_PROTOCOLS", True);
  131. dp->drv.p->wm_delete_window =
  132. XInternAtom(dp->drv.p->dpy, "WM_DELETE_WINDOW", True);
  133. if(dp->drv.p->wm_protocols != None && dp->drv.p->wm_delete_window != None)
  134. XSetWMProtocols(dp->drv.p->dpy, dp->drv.p->window,
  135. &dp->drv.p->wm_delete_window, 1);
  136. XStoreName(dp->drv.p->dpy, dp->drv.p->window, "caca for X");
  137. XSelectInput(dp->drv.p->dpy, dp->drv.p->window, StructureNotifyMask);
  138. XMapWindow(dp->drv.p->dpy, dp->drv.p->window);
  139. dp->drv.p->gc = XCreateGC(dp->drv.p->dpy, dp->drv.p->window, 0, NULL);
  140. XSetForeground(dp->drv.p->dpy, dp->drv.p->gc, dp->drv.p->colors[0x888]);
  141. XSetFont(dp->drv.p->dpy, dp->drv.p->gc, dp->drv.p->font);
  142. for(;;)
  143. {
  144. XEvent xevent;
  145. XNextEvent(dp->drv.p->dpy, &xevent);
  146. if (xevent.type == MapNotify)
  147. break;
  148. }
  149. #if defined(HAVE_X11_XKBLIB_H)
  150. /* Disable autorepeat */
  151. XkbSetDetectableAutoRepeat(dp->drv.p->dpy, True, &dp->drv.p->autorepeat);
  152. if(!dp->drv.p->autorepeat)
  153. XAutoRepeatOff(dp->drv.p->dpy);
  154. #endif
  155. dp->drv.p->event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask
  156. | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask
  157. | ExposureMask;
  158. XSelectInput(dp->drv.p->dpy, dp->drv.p->window, dp->drv.p->event_mask);
  159. XSync(dp->drv.p->dpy, False);
  160. dp->drv.p->pixmap = XCreatePixmap(dp->drv.p->dpy, dp->drv.p->window,
  161. dp->cv->width * dp->drv.p->font_width,
  162. dp->cv->height * dp->drv.p->font_height,
  163. DefaultDepth(dp->drv.p->dpy,
  164. DefaultScreen(dp->drv.p->dpy)));
  165. dp->drv.p->pointer = None;
  166. return 0;
  167. }
  168. static int x11_end_graphics(caca_display_t *dp)
  169. {
  170. XSync(dp->drv.p->dpy, False);
  171. #if defined(HAVE_X11_XKBLIB_H)
  172. if(!dp->drv.p->autorepeat)
  173. XAutoRepeatOn(dp->drv.p->dpy);
  174. #endif
  175. XFreePixmap(dp->drv.p->dpy, dp->drv.p->pixmap);
  176. XFreeFont(dp->drv.p->dpy, dp->drv.p->font_struct);
  177. XFreeGC(dp->drv.p->dpy, dp->drv.p->gc);
  178. XUnmapWindow(dp->drv.p->dpy, dp->drv.p->window);
  179. XDestroyWindow(dp->drv.p->dpy, dp->drv.p->window);
  180. XCloseDisplay(dp->drv.p->dpy);
  181. free(dp->drv.p);
  182. return 0;
  183. }
  184. static int x11_set_display_title(caca_display_t *dp, char const *title)
  185. {
  186. XStoreName(dp->drv.p->dpy, dp->drv.p->window, title);
  187. return 0;
  188. }
  189. static unsigned int x11_get_display_width(caca_display_t *dp)
  190. {
  191. return dp->cv->width * dp->drv.p->font_width;
  192. }
  193. static unsigned int x11_get_display_height(caca_display_t *dp)
  194. {
  195. return dp->cv->height * dp->drv.p->font_height;
  196. }
  197. static void x11_display(caca_display_t *dp)
  198. {
  199. unsigned int x, y, len;
  200. /* First draw the background colours. Splitting the process in two
  201. * loops like this is actually slightly faster. */
  202. for(y = 0; y < dp->cv->height; y++)
  203. {
  204. for(x = 0; x < dp->cv->width; x += len)
  205. {
  206. uint32_t *attr = dp->cv->attr + x + y * dp->cv->width;
  207. uint16_t bg = _cucul_argb32_to_rgb12bg(*attr);
  208. len = 1;
  209. while(x + len < dp->cv->width
  210. && _cucul_argb32_to_rgb12bg(attr[len]) == bg)
  211. len++;
  212. XSetForeground(dp->drv.p->dpy, dp->drv.p->gc,
  213. dp->drv.p->colors[bg]);
  214. XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->gc,
  215. x * dp->drv.p->font_width, y * dp->drv.p->font_height,
  216. len * dp->drv.p->font_width, dp->drv.p->font_height);
  217. }
  218. }
  219. /* Then print the foreground characters */
  220. for(y = 0; y < dp->cv->height; y++)
  221. {
  222. unsigned int yoff = (y + 1) * dp->drv.p->font_height
  223. - dp->drv.p->font_offset;
  224. uint32_t *chars = dp->cv->chars + y * dp->cv->width;
  225. for(x = 0; x < dp->cv->width; x++, chars++)
  226. {
  227. uint32_t *attr = dp->cv->attr + x + y * dp->cv->width;
  228. /* Skip spaces */
  229. if(*chars == 0x00000020)
  230. continue;
  231. XSetForeground(dp->drv.p->dpy, dp->drv.p->gc,
  232. dp->drv.p->colors[_cucul_argb32_to_rgb12fg(*attr)]);
  233. /* Plain ASCII, no problem. */
  234. if(*chars > 0x00000020 && *chars < 0x00000080)
  235. {
  236. char ch = (uint8_t)*chars;
  237. XDrawString(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->gc,
  238. x * dp->drv.p->font_width, yoff, &ch, 1);
  239. continue;
  240. }
  241. /* We want to be able to print a few special Unicode characters
  242. * such as the CP437 gradients and half blocks. For unknown
  243. * characters, just print '?'. */
  244. switch(*chars)
  245. {
  246. case 0x00002580: /* ▀ */
  247. XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
  248. dp->drv.p->gc,
  249. x * dp->drv.p->font_width,
  250. y * dp->drv.p->font_height,
  251. dp->drv.p->font_width,
  252. dp->drv.p->font_height / 2);
  253. break;
  254. case 0x00002584: /* ▄ */
  255. XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
  256. dp->drv.p->gc,
  257. x * dp->drv.p->font_width,
  258. (y + 1) * dp->drv.p->font_height
  259. - dp->drv.p->font_height / 2,
  260. dp->drv.p->font_width,
  261. dp->drv.p->font_height / 2);
  262. break;
  263. case 0x00002588: /* █ */
  264. XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
  265. dp->drv.p->gc,
  266. x * dp->drv.p->font_width,
  267. y * dp->drv.p->font_height,
  268. dp->drv.p->font_width,
  269. dp->drv.p->font_height);
  270. break;
  271. case 0x0000258c: /* ▌ */
  272. XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
  273. dp->drv.p->gc,
  274. x * dp->drv.p->font_width,
  275. y * dp->drv.p->font_height,
  276. dp->drv.p->font_width / 2,
  277. dp->drv.p->font_height);
  278. break;
  279. case 0x00002590: /* ▐ */
  280. XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
  281. dp->drv.p->gc,
  282. (x + 1) * dp->drv.p->font_width
  283. - dp->drv.p->font_width / 2,
  284. y * dp->drv.p->font_height,
  285. dp->drv.p->font_width / 2,
  286. dp->drv.p->font_height);
  287. break;
  288. case 0x000025a0: /* ■ */
  289. XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
  290. dp->drv.p->gc,
  291. x * dp->drv.p->font_width,
  292. y * dp->drv.p->font_height
  293. + dp->drv.p->font_height / 4,
  294. dp->drv.p->font_width,
  295. dp->drv.p->font_height / 2);
  296. break;
  297. case 0x00002593: /* ▓ */
  298. case 0x00002592: /* ▒ */
  299. case 0x00002591: /* ░ */
  300. {
  301. /* FIXME: this sucks utterly */
  302. int i, j, k = *chars - 0x00002591;
  303. for(j = dp->drv.p->font_height; j--; )
  304. for(i = dp->drv.p->font_width; i--; )
  305. {
  306. if(((i + 2 * (j & 1)) & 3) > k)
  307. continue;
  308. XDrawPoint(dp->drv.p->dpy, dp->drv.p->pixmap,
  309. dp->drv.p->gc,
  310. x * dp->drv.p->font_width + i,
  311. y * dp->drv.p->font_height + j);
  312. }
  313. break;
  314. }
  315. default:
  316. {
  317. char ch;
  318. ch = '?';
  319. XDrawString(dp->drv.p->dpy, dp->drv.p->pixmap,
  320. dp->drv.p->gc,
  321. x * dp->drv.p->font_width, yoff, &ch, 1);
  322. break;
  323. }
  324. }
  325. }
  326. }
  327. XCopyArea(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->window,
  328. dp->drv.p->gc, 0, 0,
  329. dp->cv->width * dp->drv.p->font_width,
  330. dp->cv->height * dp->drv.p->font_height,
  331. 0, 0);
  332. XFlush(dp->drv.p->dpy);
  333. }
  334. static void x11_handle_resize(caca_display_t *dp)
  335. {
  336. Pixmap new_pixmap;
  337. new_pixmap = XCreatePixmap(dp->drv.p->dpy, dp->drv.p->window,
  338. dp->resize.w * dp->drv.p->font_width,
  339. dp->resize.h * dp->drv.p->font_height,
  340. DefaultDepth(dp->drv.p->dpy,
  341. DefaultScreen(dp->drv.p->dpy)));
  342. XCopyArea(dp->drv.p->dpy, dp->drv.p->pixmap, new_pixmap,
  343. dp->drv.p->gc, 0, 0,
  344. dp->resize.w * dp->drv.p->font_width,
  345. dp->resize.h * dp->drv.p->font_height, 0, 0);
  346. XFreePixmap(dp->drv.p->dpy, dp->drv.p->pixmap);
  347. dp->drv.p->pixmap = new_pixmap;
  348. }
  349. static int x11_get_event(caca_display_t *dp, caca_event_t *ev)
  350. {
  351. XEvent xevent;
  352. char key;
  353. while(XCheckWindowEvent(dp->drv.p->dpy, dp->drv.p->window,
  354. dp->drv.p->event_mask, &xevent) == True)
  355. {
  356. KeySym keysym;
  357. /* Expose event */
  358. if(xevent.type == Expose)
  359. {
  360. XCopyArea(dp->drv.p->dpy, dp->drv.p->pixmap,
  361. dp->drv.p->window, dp->drv.p->gc, 0, 0,
  362. dp->cv->width * dp->drv.p->font_width,
  363. dp->cv->height * dp->drv.p->font_height, 0, 0);
  364. continue;
  365. }
  366. /* Resize event */
  367. if(xevent.type == ConfigureNotify)
  368. {
  369. unsigned int w, h;
  370. w = (xevent.xconfigure.width + dp->drv.p->font_width / 3)
  371. / dp->drv.p->font_width;
  372. h = (xevent.xconfigure.height + dp->drv.p->font_height / 3)
  373. / dp->drv.p->font_height;
  374. if(!w || !h || (w == dp->cv->width && h == dp->cv->height))
  375. continue;
  376. dp->resize.w = w;
  377. dp->resize.h = h;
  378. dp->resize.resized = 1;
  379. continue;
  380. }
  381. /* Check for mouse motion events */
  382. if(xevent.type == MotionNotify)
  383. {
  384. unsigned int newx = xevent.xmotion.x / dp->drv.p->font_width;
  385. unsigned int newy = xevent.xmotion.y / dp->drv.p->font_height;
  386. if(newx >= dp->cv->width)
  387. newx = dp->cv->width - 1;
  388. if(newy >= dp->cv->height)
  389. newy = dp->cv->height - 1;
  390. if(dp->mouse.x == newx && dp->mouse.y == newy)
  391. continue;
  392. dp->mouse.x = newx;
  393. dp->mouse.y = newy;
  394. ev->type = CACA_EVENT_MOUSE_MOTION;
  395. ev->data.mouse.x = dp->mouse.x;
  396. ev->data.mouse.y = dp->mouse.y;
  397. return 1;
  398. }
  399. /* Check for mouse press and release events */
  400. if(xevent.type == ButtonPress)
  401. {
  402. ev->type = CACA_EVENT_MOUSE_PRESS;
  403. ev->data.mouse.button = ((XButtonEvent *)&xevent)->button;
  404. return 1;
  405. }
  406. if(xevent.type == ButtonRelease)
  407. {
  408. ev->type = CACA_EVENT_MOUSE_RELEASE;
  409. ev->data.mouse.button = ((XButtonEvent *)&xevent)->button;
  410. return 1;
  411. }
  412. /* Check for key press and release events */
  413. if(xevent.type == KeyPress)
  414. ev->type = CACA_EVENT_KEY_PRESS;
  415. else if(xevent.type == KeyRelease)
  416. ev->type = CACA_EVENT_KEY_RELEASE;
  417. else
  418. continue;
  419. if(XLookupString(&xevent.xkey, &key, 1, NULL, NULL))
  420. {
  421. ev->data.key.ch = key;
  422. ev->data.key.ucs4 = key;
  423. ev->data.key.utf8[0] = key;
  424. ev->data.key.utf8[1] = '\0';
  425. return 1;
  426. }
  427. keysym = XKeycodeToKeysym(dp->drv.p->dpy, xevent.xkey.keycode, 0);
  428. switch(keysym)
  429. {
  430. case XK_F1: ev->data.key.ch = CACA_KEY_F1; break;
  431. case XK_F2: ev->data.key.ch = CACA_KEY_F2; break;
  432. case XK_F3: ev->data.key.ch = CACA_KEY_F3; break;
  433. case XK_F4: ev->data.key.ch = CACA_KEY_F4; break;
  434. case XK_F5: ev->data.key.ch = CACA_KEY_F5; break;
  435. case XK_F6: ev->data.key.ch = CACA_KEY_F6; break;
  436. case XK_F7: ev->data.key.ch = CACA_KEY_F7; break;
  437. case XK_F8: ev->data.key.ch = CACA_KEY_F8; break;
  438. case XK_F9: ev->data.key.ch = CACA_KEY_F9; break;
  439. case XK_F10: ev->data.key.ch = CACA_KEY_F10; break;
  440. case XK_F11: ev->data.key.ch = CACA_KEY_F11; break;
  441. case XK_F12: ev->data.key.ch = CACA_KEY_F12; break;
  442. case XK_F13: ev->data.key.ch = CACA_KEY_F13; break;
  443. case XK_F14: ev->data.key.ch = CACA_KEY_F14; break;
  444. case XK_F15: ev->data.key.ch = CACA_KEY_F15; break;
  445. case XK_Left: ev->data.key.ch = CACA_KEY_LEFT; break;
  446. case XK_Right: ev->data.key.ch = CACA_KEY_RIGHT; break;
  447. case XK_Up: ev->data.key.ch = CACA_KEY_UP; break;
  448. case XK_Down: ev->data.key.ch = CACA_KEY_DOWN; break;
  449. case XK_KP_Page_Up:
  450. case XK_Page_Up: ev->data.key.ch = CACA_KEY_PAGEUP; break;
  451. case XK_KP_Page_Down:
  452. case XK_Page_Down: ev->data.key.ch = CACA_KEY_PAGEDOWN; break;
  453. case XK_KP_Home:
  454. case XK_Home: ev->data.key.ch = CACA_KEY_HOME; break;
  455. case XK_KP_End:
  456. case XK_End: ev->data.key.ch = CACA_KEY_END; break;
  457. default: ev->type = CACA_EVENT_NONE; return 0;
  458. }
  459. ev->data.key.ucs4 = 0;
  460. ev->data.key.utf8[0] = '\0';
  461. return 1;
  462. }
  463. while(XCheckTypedEvent(dp->drv.p->dpy, ClientMessage, &xevent))
  464. {
  465. if(xevent.xclient.message_type != dp->drv.p->wm_protocols)
  466. continue;
  467. if((Atom)xevent.xclient.data.l[0] == dp->drv.p->wm_delete_window)
  468. {
  469. ev->type = CACA_EVENT_QUIT;
  470. return 1;
  471. }
  472. }
  473. ev->type = CACA_EVENT_NONE;
  474. return 0;
  475. }
  476. static void x11_set_mouse(caca_display_t *dp, int flags)
  477. {
  478. Cursor no_ptr;
  479. Pixmap bm_no;
  480. XColor black, dummy;
  481. Colormap colormap;
  482. static char const empty[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
  483. if(flags)
  484. {
  485. XDefineCursor(dp->drv.p->dpy,dp->drv.p->window, 0);
  486. return;
  487. }
  488. colormap = DefaultColormap(dp->drv.p->dpy, DefaultScreen(dp->drv.p->dpy));
  489. if(!XAllocNamedColor(dp->drv.p->dpy, colormap, "black", &black, &dummy))
  490. {
  491. return;
  492. }
  493. bm_no = XCreateBitmapFromData(dp->drv.p->dpy, dp->drv.p->window,
  494. empty, 8, 8);
  495. no_ptr = XCreatePixmapCursor(dp->drv.p->dpy, bm_no, bm_no,
  496. &black, &black, 0, 0);
  497. XDefineCursor(dp->drv.p->dpy, dp->drv.p->window, no_ptr);
  498. XFreeCursor(dp->drv.p->dpy, no_ptr);
  499. if(bm_no != None)
  500. XFreePixmap(dp->drv.p->dpy, bm_no);
  501. XFreeColors(dp->drv.p->dpy, colormap, &black.pixel, 1, 0);
  502. XSync(dp->drv.p->dpy, False);
  503. }
  504. /*
  505. * XXX: following functions are local
  506. */
  507. static int x11_error_handler(Display *dpy, XErrorEvent *xevent)
  508. {
  509. /* Ignore the error */
  510. return 0;
  511. }
  512. /*
  513. * Driver initialisation
  514. */
  515. int x11_install(caca_display_t *dp)
  516. {
  517. #if defined(HAVE_GETENV)
  518. if(!getenv("DISPLAY") || !*(getenv("DISPLAY")))
  519. return -1;
  520. #endif
  521. dp->drv.driver = CACA_DRIVER_X11;
  522. dp->drv.init_graphics = x11_init_graphics;
  523. dp->drv.end_graphics = x11_end_graphics;
  524. dp->drv.set_display_title = x11_set_display_title;
  525. dp->drv.get_display_width = x11_get_display_width;
  526. dp->drv.get_display_height = x11_get_display_height;
  527. dp->drv.display = x11_display;
  528. dp->drv.handle_resize = x11_handle_resize;
  529. dp->drv.get_event = x11_get_event;
  530. dp->drv.set_mouse = x11_set_mouse;
  531. return 0;
  532. }
  533. #endif /* USE_X11 */