/package/fltk/fltk-1.1.9-directfb-support.patch

http://buildroot.googlecode.com/ · Patch · 2177 lines · 2156 code · 21 blank · 0 comment · 0 complexity · d3d89cc0465b62ae921600156a3024d4 MD5 · raw file

Large files are truncated click here to view the full file

  1. diff -Nwrup -x.git fltk-1.1.9/configh.in FLTK_1.x-DirectFB/configh.in
  2. --- fltk-1.1.9/configh.in 2007-02-08 15:14:30.000000000 -0500
  3. +++ FLTK_1.x-DirectFB/configh.in 2009-11-28 15:48:05.869153408 -0500
  4. @@ -131,6 +131,15 @@
  5. #undef __APPLE_QD__
  6. /*
  7. + * DIRECTFB:
  8. + *
  9. + * All drawing function use DirectFB library.
  10. + *
  11. + */
  12. +
  13. +#define DIRECTFB 0
  14. +
  15. +/*
  16. * HAVE_OVERLAY:
  17. *
  18. * Use the X overlay extension? FLTK will try to use an overlay
  19. diff -Nwrup -x.git fltk-1.1.9/configure FLTK_1.x-DirectFB/configure
  20. --- fltk-1.1.9/configure 2008-04-27 04:28:21.000000000 -0400
  21. +++ FLTK_1.x-DirectFB/configure 2009-11-28 15:48:05.872152486 -0500
  22. @@ -1316,6 +1316,7 @@ Optional Features:
  23. --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
  24. --enable-cygwin use the CygWin libraries default=no
  25. --enable-debug turn on debugging default=no
  26. + --enable-directfb turn on DirectFB support default=no
  27. --enable-gl turn on OpenGL support default=yes
  28. --enable-shared turn on shared libraries default=no
  29. --enable-threads enable multi-threading support
  30. @@ -1859,6 +1860,12 @@ else
  31. DEBUGFLAG=""
  32. fi
  33. +# Check whether --enable-directfb was given.
  34. +if test "${enable_directfb+set}" = set; then
  35. + enableval=$enable_directfb;
  36. +fi
  37. +
  38. +
  39. # Check whether --enable-gl was given.
  40. if test "${enable_gl+set}" = set; then
  41. enableval=$enable_gl;
  42. @@ -9217,6 +9224,17 @@ _ACEOF
  43. THREADS="threads"
  44. fi
  45. + if test x$enable_directfb == xyes; then
  46. + cat >>confdefs.h <<\_ACEOF
  47. +#define DIRECTFB 1
  48. +_ACEOF
  49. +
  50. + cat >>confdefs.h <<\_ACEOF
  51. +#define USE_COLORMAP 0
  52. +_ACEOF
  53. +
  54. + LIBS="$LIBS -ldirect -ldirectfb -lfusion $X_EXTRA_LIBS"
  55. + else
  56. { echo "$as_me:$LINENO: checking for X" >&5
  57. echo $ECHO_N "checking for X... $ECHO_C" >&6; }
  58. @@ -10544,6 +10562,7 @@ echo "$as_me: WARNING: Ignoring librarie
  59. fi
  60. LIBS="$LIBS -lXext -lX11 $X_EXTRA_LIBS"
  61. + fi
  62. CFLAGS="$CFLAGS $X_CFLAGS"
  63. CXXFLAGS="$CXXFLAGS $X_CFLAGS"
  64. LDFLAGS="$X_LIBS $LDFLAGS"
  65. @@ -12001,6 +12020,9 @@ case $uname in
  66. fi
  67. ;;
  68. *)
  69. + if test x$enable_directfb = xyes; then
  70. + graphics="DirectFB"
  71. + else
  72. graphics="X11"
  73. if test x$enable_xft = xyes; then
  74. graphics="$graphics+Xft"
  75. @@ -12011,6 +12033,7 @@ case $uname in
  76. if test x$enable_xinerama = xyes; then
  77. graphics="$graphics+Xinerama"
  78. fi
  79. + fi
  80. ;;
  81. esac
  82. diff -Nwrup -x.git fltk-1.1.9/configure.in FLTK_1.x-DirectFB/configure.in
  83. --- fltk-1.1.9/configure.in 2008-04-11 12:53:01.000000000 -0400
  84. +++ FLTK_1.x-DirectFB/configure.in 2009-11-28 15:48:05.873159527 -0500
  85. @@ -117,6 +117,8 @@ else
  86. DEBUGFLAG=""
  87. fi
  88. +AC_ARG_ENABLE(directfb, [ --enable-directfb turn on DirectFB support [default=no]])
  89. +
  90. AC_ARG_ENABLE(gl, [ --enable-gl turn on OpenGL support [default=yes]])
  91. AC_ARG_ENABLE(shared, [ --enable-shared turn on shared libraries [default=no]])
  92. @@ -696,6 +698,11 @@ case $uname in
  93. THREADS="threads"
  94. fi
  95. + if test x$enable_directfb == xyes; then
  96. + AC_DEFINE(DIRECTFB,1)
  97. + AC_DEFINE(USE_COLORMAP,0)
  98. + LIBS="$LIBS -ldirect -ldirectfb -lfusion $X_EXTRA_LIBS"
  99. + else
  100. dnl Check for X11...
  101. AC_PATH_XTRA
  102. @@ -708,6 +715,7 @@ case $uname in
  103. fi
  104. LIBS="$LIBS -lXext -lX11 $X_EXTRA_LIBS"
  105. + fi
  106. CFLAGS="$CFLAGS $X_CFLAGS"
  107. CXXFLAGS="$CXXFLAGS $X_CFLAGS"
  108. LDFLAGS="$X_LIBS $LDFLAGS"
  109. @@ -1091,6 +1099,9 @@ case $uname in
  110. fi
  111. ;;
  112. *)
  113. + if test x$enable_directfb = xyes; then
  114. + graphics="DirectFB"
  115. + else
  116. graphics="X11"
  117. if test x$enable_xft = xyes; then
  118. graphics="$graphics+Xft"
  119. @@ -1101,6 +1112,7 @@ case $uname in
  120. if test x$enable_xinerama = xyes; then
  121. graphics="$graphics+Xinerama"
  122. fi
  123. + fi
  124. ;;
  125. esac
  126. diff -Nwrup -x.git fltk-1.1.9/FL/DirectFB.H FLTK_1.x-DirectFB/FL/DirectFB.H
  127. --- fltk-1.1.9/FL/DirectFB.H 1969-12-31 19:00:00.000000000 -0500
  128. +++ FLTK_1.x-DirectFB/FL/DirectFB.H 2009-11-28 15:48:05.842154085 -0500
  129. @@ -0,0 +1,667 @@
  130. +//
  131. +// "$Id: DirectFB.H,v 1.3 2006-10-31 09:31:14 nikego Exp $"
  132. +//
  133. +// DirectFB header file for the Fast Light Tool Kit (FLTK).
  134. +//
  135. +// Copyright 1998-2005 by Bill Spitzak and others.
  136. +//
  137. +// This library is free software; you can redistribute it and/or
  138. +// modify it under the terms of the GNU Library General Public
  139. +// License as published by the Free Software Foundation; either
  140. +// version 2 of the License, or (at your option) any later version.
  141. +//
  142. +// This library is distributed in the hope that it will be useful,
  143. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  144. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  145. +// Library General Public License for more details.
  146. +//
  147. +// You should have received a copy of the GNU Library General Public
  148. +// License along with this library; if not, write to the Free Software
  149. +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  150. +// USA.
  151. +//
  152. +// Please report all bugs and problems on the following page:
  153. +//
  154. +// http://www.fltk.org/str.php
  155. +//
  156. +
  157. +// Do not directly include this file, instead use <FL/x.H>. It will
  158. +// include this file if DIRECTFB is defined. This is to encourage
  159. +// portability of even the system-specific code...
  160. +
  161. +#ifndef Fl_X_H
  162. +# error "Never use <DirectFB.H> directly; include <FL/x.H> instead."
  163. +#endif // !Fl_X_H
  164. +
  165. +#include <config.h>
  166. +
  167. +// to make debug version uncomment the next line
  168. +//#define DEBUG 1
  169. +
  170. +#ifdef DEBUG
  171. +// to enable DirectFB's debug tracing
  172. +# define DIRECT_ENABLE_DEBUG (1)
  173. +#endif
  174. +
  175. +#include <directfb.h>
  176. +#include <directfb_version.h>
  177. +#include <FL/xutils.h>
  178. +
  179. +// In some of the distributions, the gcc header files are missing some stuff:
  180. +#ifndef LPMINMAXINFO
  181. +#define LPMINMAXINFO MINMAXINFO*
  182. +#endif
  183. +#ifndef VK_LWIN
  184. +#define VK_LWIN 0x5B
  185. +#define VK_RWIN 0x5C
  186. +#define VK_APPS 0x5D
  187. +#endif
  188. +
  189. +#include <stdio.h>
  190. +
  191. +// This is the super interface, it's the entry point to all functionality.
  192. +extern IDirectFB* fl_dfb;
  193. +extern IDirectFBDisplayLayer* fl_display_layer;
  194. +extern GC fl_screen; //The primary surface, i.e. the "screen".
  195. +
  196. +void print_last_dump();
  197. +
  198. +#ifdef DEBUG
  199. +
  200. +#define DFBCHECK(x...)\
  201. + {\
  202. + DFBResult err = x;\
  203. + if (err != DFB_OK){\
  204. + fprintf( stderr, "Error '%s' occured in %s <%d>:\n\t", DirectFBErrorString(err), __FILE__, __LINE__ );\
  205. + fprintf( stderr, #x );\
  206. + print_last_dump();\
  207. + /* DirectFBErrorFatal( #x, err );*/\
  208. + }\
  209. + }
  210. +
  211. +#else
  212. +
  213. + #define DFBCHECK(x...) x
  214. +
  215. +#endif
  216. +
  217. +/******************************************************/
  218. +/* DirectFB's assist functions */
  219. +/******************************************************/
  220. +
  221. +static inline int
  222. +get_caps( GC gc ){
  223. + DFBSurfaceCapabilities ret_caps = DSCAPS_NONE;
  224. + if (gc && gc->surface)
  225. + DFBCHECK(gc->surface->GetCapabilities(gc->surface, &ret_caps));
  226. + return ret_caps;
  227. +}
  228. +
  229. +static inline int
  230. +get_pixel_format(GC gc){
  231. + DFBSurfacePixelFormat pixel_format = DSPF_UNKNOWN;
  232. + if (gc && gc->surface)
  233. + gc->surface->GetPixelFormat(gc->surface, &pixel_format);
  234. + return (int)pixel_format;
  235. +}
  236. +
  237. +static inline void
  238. +get_size(GC gc, int* width, int* height ){
  239. + if (gc && gc->surface)
  240. + DFBCHECK(gc->surface->GetSize(gc->surface, width, height));
  241. +}
  242. +
  243. +static inline void
  244. +get_visible_rectangle( GC gc, DFBRectangle* rect ){
  245. + if (gc && gc->surface)
  246. + DFBCHECK( gc->surface->GetVisibleRectangle( gc->surface, rect ) );
  247. +}
  248. +
  249. +// summary
  250. +static inline int
  251. +get_surface_description(GC gc, DFBSurfaceDescription* desc){
  252. + if (gc && gc->surface) {
  253. + desc->flags = (DFBSurfaceDescriptionFlags)(DSDESC_CAPS|DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT);
  254. + desc->caps = (DFBSurfaceCapabilities)get_caps( gc );
  255. + get_size( gc, &desc->width , &desc->height );
  256. + desc->pixelformat = (DFBSurfacePixelFormat)get_pixel_format( gc );
  257. + return DFB_OK;
  258. + }
  259. + return DFB_INVARG;
  260. +}
  261. +
  262. +static inline void
  263. +get_palette(GC gc, IDirectFBPalette** pal){
  264. + if (gc && gc->surface)
  265. + DFBCHECK( gc->surface->GetPalette( gc->surface, pal ) );
  266. +}
  267. +
  268. +static inline void*
  269. +lock_surface(GC gc, int flags, int *ret_pitch){
  270. + void* buffer = 0;
  271. + if (gc && gc->surface)
  272. + if (DFB_OK == gc->surface->Lock(gc->surface, (DFBSurfaceLockFlags)flags,\
  273. + &buffer, ret_pitch))
  274. + return buffer;
  275. + return 0;
  276. +}
  277. +
  278. +static inline void
  279. +unlock_surface(GC gc){
  280. + if (gc && gc->surface)
  281. + gc->surface->Unlock( gc->surface );
  282. +}
  283. +
  284. +static inline void
  285. +flip_gc(GC gc, DFBRegion *region, int flags){
  286. + DFBCHECK(gc->surface->Flip( gc->surface, region,( DFBSurfaceFlipFlags)flags ) );
  287. +}
  288. +
  289. +static inline void
  290. +clear_gc(GC gc, uchar red, uchar green, uchar blue, uchar alpha){
  291. + if (gc && gc->surface)
  292. + DFBCHECK(gc->surface->Clear(gc->surface, red, green, blue, alpha));
  293. +}
  294. +
  295. +static inline int
  296. +set_clip(GC gc, DFBRegion* reg){
  297. + if (gc && gc->surface){
  298. + if( reg ){
  299. + DFBRegion r = *reg;
  300. + if (r.x2) r.x2--;
  301. + if (r.y2) r.y2--;
  302. + return gc->surface->SetClip( gc->surface, &r );
  303. + }else
  304. + return gc->surface->SetClip( gc->surface, reg );
  305. + }
  306. + return DFB_INVARG;
  307. +}
  308. +
  309. +static inline int
  310. +get_clip(GC gc, DFBRegion* reg){
  311. + if (gc && gc->surface)
  312. + if (reg){
  313. + return gc->surface->GetClip(gc->surface, reg);
  314. + }
  315. + return DFB_INVARG;
  316. +}
  317. +
  318. +inline void
  319. +set_drawing_flags(GC gc, int flags){
  320. + if (gc && gc->surface)
  321. + DFBCHECK(gc->surface->SetDrawingFlags(gc->surface, (DFBSurfaceDrawingFlags)flags));
  322. +}
  323. +
  324. +static inline void
  325. +set_src_blend_function( GC gc, int func ){
  326. + if (gc && gc->surface)
  327. + gc->surface->SetSrcBlendFunction( gc->surface, (DFBSurfaceBlendFunction) func );
  328. +}
  329. +
  330. +static inline void
  331. +set_dst_blend_function( GC gc, int func ){
  332. + if (gc && gc->surface)
  333. + gc->surface->SetDstBlendFunction( gc->surface, (DFBSurfaceBlendFunction) func );
  334. +}
  335. +
  336. +static inline void
  337. +set_porter_duff(GC gc, int rule){
  338. + if (gc && gc->surface)
  339. + gc->surface->SetPorterDuff( gc->surface, (DFBSurfacePorterDuffRule)rule );
  340. +}
  341. +
  342. +static inline void
  343. +set_blitting_flags(GC gc, int flags){
  344. + DFBCHECK( gc->surface->SetBlittingFlags(gc->surface, (DFBSurfaceBlittingFlags)flags ) );
  345. +}
  346. +
  347. +static inline void
  348. +blit(GC dest,GC src, DFBRectangle* rect, int x , int y){
  349. + if (src && dest && dest->surface && src->surface)
  350. + DFBCHECK(dest->surface->Blit(dest->surface,src->surface, rect, x, y));
  351. +}
  352. +
  353. +static inline void
  354. +set_surface_font(GC gc, IDirectFBFont* font){
  355. + if (gc && gc->surface)
  356. + DFBCHECK(gc->surface->SetFont(gc->surface, font));
  357. +}
  358. +
  359. +static inline IDirectFBFont*
  360. +get_surface_font(GC gc){
  361. + IDirectFBFont* ret_font = 0;
  362. + if (gc && gc->surface)
  363. + gc->surface->GetFont(gc->surface, &ret_font);
  364. + return ret_font;
  365. +}
  366. +
  367. +static inline int
  368. +set_color(GC gc, u8 _r,u8 _g,u8 _b,u8 _a){
  369. + if (gc && gc->surface)
  370. + {
  371. + gc->r = _r;
  372. + gc->g = _g;
  373. + gc->b = _b;
  374. + gc->a = _a;
  375. + DFBCHECK( gc->surface->SetColor( gc->surface,_r,_g,_b,_a ) );
  376. + }
  377. + return 0;
  378. +}
  379. +
  380. +/*static inline int
  381. +set_color(GC gc, u8 _color){
  382. + if (gc && gc->surface)
  383. + DFBCHECK( gc->surface->SetColorIndex(gc->surface, _color));
  384. + return 0;
  385. +}*/
  386. +
  387. +static inline int
  388. +set_src_color_key(GC gc, u8 _color){
  389. + if (gc && gc->surface)
  390. + DFBCHECK(gc->surface->SetSrcColorKeyIndex(gc->surface, _color));
  391. + return 0;
  392. +}
  393. +
  394. +static inline int
  395. +set_src_color_key(GC gc, u8 r, u8 g, u8 b){
  396. + if (gc && gc->surface)
  397. + DFBCHECK(gc->surface->SetSrcColorKey( gc->surface, r, g, b));
  398. + return 0;
  399. +}
  400. +
  401. +static inline int
  402. +set_dst_color_key( GC gc, u8 _color ){
  403. + DFBCHECK(gc->surface->SetDstColorKeyIndex(gc->surface, _color ));
  404. + return 0;
  405. +}
  406. +
  407. +static inline int
  408. +set_dst_color_key(GC gc, u8 r, u8 g , u8 b ){
  409. + if (gc && gc->surface)
  410. + DFBCHECK(gc->surface->SetDstColorKey(gc->surface, r, g, b));
  411. + return 0;
  412. +}
  413. +
  414. +void
  415. +draw_lines(GC gc, Region reg, int n );
  416. +
  417. +void
  418. +draw_string(GC gc, const char* str, int n, int x, int y, DFBSurfaceTextFlags flags );
  419. +
  420. +void
  421. +get_string_width(IDirectFBFont *font, const char* s, int n, int * width);
  422. +
  423. +int
  424. +set_clip_mask(Pixmap mask);
  425. +
  426. +/*********************************************************************
  427. + * window's functions
  428. + * */
  429. +
  430. +static inline DFBWindowID
  431. +get_id( IDirectFBWindow* window ){
  432. + DFBWindowID ret_id;
  433. + if ( window && ( DFB_OK == window->GetID( window, &ret_id ) ) )
  434. + return ret_id;
  435. + return 0;
  436. +}
  437. +
  438. +static inline void
  439. +set_opacity(IDirectFBWindow* window, int opacity){
  440. + if (window)
  441. + DFBCHECK( window->SetOpacity( window, opacity ) );
  442. +}
  443. +
  444. +static inline int
  445. +get_opacity(IDirectFBWindow* window){
  446. + uchar ret_op;
  447. + if (window)
  448. + DFBCHECK(window->GetOpacity(window, &ret_op));
  449. + return ret_op;
  450. +}
  451. +
  452. +static inline void
  453. +get_size(IDirectFBWindow* window, int* width, int* height){
  454. + if (window)
  455. + DFBCHECK(window->GetSize(window, width, height));
  456. +}
  457. +
  458. +static inline void
  459. +resize( IDirectFBWindow* window, int width, int height){
  460. + if (window)
  461. + DFBCHECK(window->ResizeSurface(window, width, height));
  462. +}
  463. +
  464. +static inline void
  465. +get_position(IDirectFBWindow* window,int* x, int* y){
  466. + if (window)
  467. + DFBCHECK(window->GetPosition(window, x, y));
  468. +}
  469. +
  470. +static inline void
  471. +set_cursor_shape(IDirectFBDisplayLayer* layer, GC cursor, int hot_x, int hot_y){
  472. + if (layer)
  473. + DFBCHECK(layer->SetCursorShape(layer, cursor ? cursor->surface : 0, hot_x, hot_y));
  474. +}
  475. +
  476. +static inline void
  477. +raise_to_top(IDirectFBWindow* window){
  478. + if (window)
  479. + DFBCHECK(window->RaiseToTop(window));
  480. +}
  481. +
  482. +
  483. +/**********************************************************************/
  484. +
  485. +static inline void
  486. +wait_for_event_with_timeout(IDirectFBEventBuffer* buffer, unsigned sec, unsigned msec){
  487. + if (buffer)
  488. + DFBCHECK( buffer->WaitForEventWithTimeout( buffer, sec, msec ) );
  489. +}
  490. +
  491. +static inline void
  492. +set_cursor_opacity(IDirectFBDisplayLayer* layer, int opacity){
  493. + if (layer)
  494. + DFBCHECK(layer->SetCursorOpacity(layer, opacity));
  495. +}
  496. +
  497. +static inline void
  498. +get_cursor_position(IDirectFBDisplayLayer* layer, int* xx, int* yy){
  499. + if (layer)
  500. + DFBCHECK( layer->GetCursorPosition( layer, xx, yy ) );
  501. +}
  502. +
  503. +GC
  504. +create_gc(const DFBSurfaceDescription* desc);
  505. +
  506. +GC
  507. +create_gc(IDirectFBWindow* window);
  508. +
  509. +GC
  510. +create_gc(GC parent_gc, const DFBRectangle* rect);
  511. +
  512. +GC
  513. +create_gc(int caps, int flags, int pixelformat, int width, int height);
  514. +
  515. +IDirectFBWindow*
  516. +create_window(const DFBWindowDescription* desc);
  517. +
  518. +IDirectFBWindow*
  519. +get_window( DFBWindowID xid );
  520. +
  521. +static inline void
  522. +grab_pointer(IDirectFBWindow* window){
  523. + if (window)
  524. + DFBCHECK( window->GrabPointer( window ) );
  525. +}
  526. +
  527. +static inline void
  528. +ungrab_pointer(IDirectFBWindow* window){
  529. + if (window)
  530. + DFBCHECK(window->UngrabPointer(window));
  531. +}
  532. +
  533. +static inline void
  534. +set_win_cursor_shape(IDirectFBWindow* win, GC cursor, int hot_x, int hot_y){
  535. + if (win)
  536. + DFBCHECK(win->SetCursorShape(win, cursor ? cursor->surface : 0, hot_x, hot_y));
  537. +}
  538. +
  539. +
  540. +static inline void
  541. +set_options(IDirectFBWindow* window, int opts){
  542. + if (window)
  543. + DFBCHECK(window->SetOptions(window, (DFBWindowOptions)opts));
  544. +}
  545. +
  546. +static inline int
  547. +create_font(const char* filename, const DFBFontDescription* desc, IDirectFBFont** ret_interface){
  548. + if (fl_dfb)
  549. + fl_dfb->CreateFont(fl_dfb, filename, desc, ret_interface);
  550. + return 0;
  551. +}
  552. +
  553. +static inline int
  554. +get_font_height( IDirectFBFont* font ){
  555. + int height=0;
  556. + if (font && ( DFB_OK == font->GetHeight(font, &height)))
  557. + return height;
  558. + return 0;
  559. +}
  560. +
  561. +static inline int
  562. +get_font_descender( IDirectFBFont* font ){
  563. + int descender=0;
  564. + if( font && ( DFB_OK == font->GetDescender( font, &descender ) ) )
  565. + return -descender;
  566. + return 0;
  567. +}
  568. +
  569. +static inline int
  570. +get_surface_description( IDirectFBImageProvider* image_provider, DFBSurfaceDescription* desc ){
  571. + if (image_provider)
  572. + image_provider->GetSurfaceDescription( image_provider, desc );
  573. + return DFB_OK;
  574. +}
  575. +
  576. +static inline IDirectFBImageProvider*
  577. +create_image_provider(const char *name){
  578. + IDirectFBImageProvider *image_provider;
  579. + if (fl_dfb && (DFB_OK == fl_dfb->CreateImageProvider(fl_dfb, name, &image_provider)) )
  580. + return image_provider;
  581. + return 0;
  582. +}
  583. +
  584. +static inline void
  585. +render_to( IDirectFBImageProvider *image_provider, GC gc, DFBRectangle* rect ){
  586. + if (image_provider)
  587. + image_provider->RenderTo( image_provider, gc->surface, rect );
  588. +}
  589. +
  590. +static inline void
  591. +release( IDirectFBSurface* s ){
  592. + if (s && fl_dfb)
  593. + s->Release( s );
  594. +}
  595. +
  596. +static inline void
  597. +release( IDirectFBWindow *w ){
  598. + if (w && fl_dfb)
  599. + w->Release( w );
  600. +}
  601. +
  602. +static inline void
  603. +release( IDirectFBInputDevice* d ){
  604. + if (d && fl_dfb)
  605. + d->Release( d );
  606. +}
  607. +
  608. +extern void print_gc_list();
  609. +extern void free_gc_list();
  610. +extern void fl_free_cursors();
  611. +extern void _fl_show_cursor(int);
  612. +
  613. +#define fl_display fl_display_layer
  614. +#define xdisplay fl_display_layer
  615. +#define Fl_Region Region
  616. +#define display_layer fl_display_layer
  617. +
  618. +static inline int
  619. +pixel_format(){
  620. + extern u32 pixf_;
  621. + return pixf_;
  622. +}
  623. +
  624. +static inline bool
  625. +have_lut(){
  626. + extern bool lut_;
  627. + return lut_;
  628. +}
  629. +
  630. +int fl_init_dfb(int argc, char **argv);
  631. +
  632. +FL_EXPORT void fl_clip_region(Fl_Region);
  633. +
  634. +#include "Fl_Window.H"
  635. +// this object contains all directfb-specific stuff about a window:
  636. +// Warning: this object is highly subject to change!
  637. +FL_EXPORT void fl_open_display();
  638. +FL_EXPORT void fl_open_display(Display*);
  639. +FL_EXPORT void fl_close_display();
  640. +
  641. +extern VisualInfo visual_info;
  642. +extern FL_EXPORT dfbWindow fl_message_window;
  643. +extern FL_EXPORT VisualInfo* fl_visual;
  644. +extern FL_EXPORT Colormap fl_colormap;
  645. +extern FL_EXPORT Surface fl_gc;
  646. +extern FL_EXPORT Window fl_window;
  647. +extern FL_EXPORT IDirectFBFont* fl_xfont;
  648. +
  649. +extern FL_EXPORT ulong fl_xpixel(Fl_Color i);
  650. +extern FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
  651. +extern FL_EXPORT void fl_clip_region(Fl_Region);
  652. +extern FL_EXPORT Fl_Region fl_clip_region();
  653. +
  654. +// feed events into fltk:
  655. +FL_EXPORT int fl_handle(const DFBWindowEvent&);
  656. +
  657. +// you can use these in Fl::add_handler() to look at events:
  658. +//extern FL_EXPORT const DFBWindowEvent* fl_xevent;
  659. +extern FL_EXPORT ulong fl_event_time;
  660. +
  661. +// flip a rectangle of screen
  662. +FL_EXPORT void fl_flip( GC surf, int x, int y, int w, int h );
  663. +FL_EXPORT void fl_flip( int x, int y, int w, int h );
  664. +FL_EXPORT void fl_flip( GC surf, Region r );
  665. +
  666. +/*******************************************************/
  667. +// off-screen pixmaps: create, destroy, draw into, copy to window:
  668. +
  669. +typedef Pixmap Fl_Offscreen;
  670. +
  671. +Fl_Offscreen fl_create_offscreen(int w,int h);
  672. +Fl_Offscreen fl_create_offscreen_argb(int w,int h);//with alpha mask
  673. +
  674. +void fl_delete_offscreen(Fl_Offscreen);
  675. +
  676. +// begin/end are functions that save the old state in global variables:
  677. +
  678. +void fl_begin_offscreen(Fl_Offscreen);
  679. +void fl_end_offscreen();
  680. +void fl_copy_offscreen(int _x,int _y,int _w,int _h,Fl_Offscreen offscreen,int srcx,int srcy);
  681. +void fl_copy_offscreen_bk(int _x,int _y,int _w,int _h,Fl_Offscreen offscreen,int srcx,int srcy,ulong bkcolor );
  682. +//void fl_copy_offscreen_with_mask(int _x, int _y, int _w, int _h, void* offscreen, int srcx, int srcy, void* mask );
  683. +void fl_draw_abgr_to_argb(const uchar* array, int x, int y, int w, int h);
  684. +
  685. +
  686. +#if 0 //FIXME SetDstColorKeyIndex is not working !
  687. + extern int _dstcol_Blit( GC,GC,DFBRectangle*, int,int,int );
  688. +# define __Blit( s ,i, r, x ,y, c ) _dstcol_Blit( s ,i, r, x ,y, c )
  689. +#else
  690. +# define __Blit( s ,i, r, x ,y, c ) _Blit( s ,i, r, x ,y )
  691. +#endif
  692. +
  693. +GC
  694. +fl_load_image( const char *infname, int& w, int& h, GC* mask );
  695. +
  696. +uchar*
  697. +fl_load_image( const char *infname, int& w, int& h, int& d );
  698. +
  699. +int
  700. +BitBlit( GC dest, int dest_x, int dest_y, int width, int height,GC src, int src_x,int src_y );
  701. +
  702. +/*************************************************************************************/
  703. +/* Bitmap masks */
  704. +
  705. +typedef Fl_Offscreen Fl_Bitmask;
  706. +
  707. +extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
  708. +extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
  709. +extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
  710. +
  711. +#define CHILD_ID 0x8000
  712. +
  713. +/*************************************************************************************/
  714. +// this object contains all X-specific stuff about a window:
  715. +// Warning: this object is highly subject to change! It's definition
  716. +// is only here so that fl_xid can be declared inline:
  717. +class FL_EXPORT Fl_X {
  718. +public:
  719. + XID xid;
  720. + dfbWindow _xid;
  721. + Fl_Window* w;
  722. + Fl_Region region;
  723. + GC gc; //client's context
  724. + GC win_gc;//window's context
  725. +
  726. + char wait_for_expose;
  727. + char backbuffer_bad; // used for XDBE
  728. +
  729. + static Fl_X* first;
  730. + Fl_X *next;
  731. + static Fl_X* i(const Fl_Window* wi) {return wi->i;}
  732. +/*------------------------------------------------------------------------*/
  733. + void setwindow( Fl_Window* wi ) {w=wi; wi->i=this;}
  734. + void sendxjunk();
  735. + static Fl_X* make_xid(Fl_Window*);
  736. + static Fl_X* set_xid(Fl_Window*, dfbWindow);
  737. + char first_draw;//FIXME it's a flag to show the window after first drawing
  738. + // kludges to get around protection:
  739. + void flush();
  740. + static void x(Fl_Window* wi, int X) {wi->x(X);}
  741. + static void y(Fl_Window* wi, int Y) {wi->y(Y);}
  742. + static void release();
  743. +
  744. + Fl_Window *header;
  745. + void draw_window_frame();
  746. + void enter_window(bool);
  747. + void set_gc(int W=-1,int H=-1);
  748. + DFBRectangle origin_size;
  749. + int minimize_;
  750. + int maximize(){return origin_size.w!=0;};
  751. + void set_maximize();
  752. + int minimize(){return minimize_;}
  753. + void delete_icon();
  754. + void set_minimize();
  755. + void restore_size(int X=-1,int Y=-1,int W=-1,int H=-1);
  756. + short minw,minh,maxw,maxh,dw,dh;
  757. + Cursor cursors[2];
  758. +};
  759. +
  760. +//compatibitily with FLTK2
  761. +#define CreatedWindow Fl_X
  762. +
  763. +// convert xid <-> Fl_Window:
  764. +/*static inline WindowID fl_wnd(const Fl_Window* w){
  765. + return Fl_X::i(w)->_xid;
  766. +}*/
  767. +static inline Window fl_xid(const Fl_Window* w){
  768. + return Fl_X::i(w)->xid;
  769. +}
  770. +
  771. +FL_EXPORT Fl_Window* fl_find( Window xid );
  772. +FL_EXPORT Fl_Window* fl_find( dfbWindow _xid );
  773. +
  774. +Fl_X *get_parent_xid( Fl_Widget* w );
  775. +
  776. +void delete_icon( Fl_Window* win );
  777. +
  778. +extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
  779. +extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid()
  780. +
  781. +// Dummy function to register a function for opening files via the window manager...
  782. +static inline void fl_open_callback(void (*)(const char *)) {
  783. +}
  784. +
  785. +extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
  786. +extern FL_EXPORT void fl_free_dfbfonts();
  787. +
  788. +void fl_deinit_dfb(void);
  789. +
  790. +#if USE_COLORMAP
  791. +void init_xcolormap();
  792. +#endif
  793. +
  794. +//
  795. +// End of "$Id: DirectFB.H,v 1.3 2006-10-31 09:31:14 nikego Exp $".
  796. +//
  797. diff -Nwrup -x.git fltk-1.1.9/FL/Fl_GIF_Image.H FLTK_1.x-DirectFB/FL/Fl_GIF_Image.H
  798. --- fltk-1.1.9/FL/Fl_GIF_Image.H 2005-04-15 20:13:17.000000000 -0400
  799. +++ FLTK_1.x-DirectFB/FL/Fl_GIF_Image.H 2009-11-28 15:48:05.845154140 -0500
  800. @@ -1,5 +1,5 @@
  801. //
  802. -// "$Id: Fl_GIF_Image.H 4288 2005-04-16 00:13:17Z mike $"
  803. +// "$Id: Fl_GIF_Image.H,v 1.1 2006-04-06 14:01:27 nikego Exp $"
  804. //
  805. // GIF image header file for the Fast Light Tool Kit (FLTK).
  806. //
  807. @@ -28,8 +28,15 @@
  808. #ifndef Fl_GIF_Image_H
  809. #define Fl_GIF_Image_H
  810. # include "Fl_Pixmap.H"
  811. +#include <config.h>
  812. -class FL_EXPORT Fl_GIF_Image : public Fl_Pixmap {
  813. +class FL_EXPORT Fl_GIF_Image : public
  814. +#ifndef DIRECTFB
  815. + Fl_Pixmap
  816. +#else
  817. + Fl_RGB_Image
  818. +#endif
  819. + {
  820. public:
  821. @@ -39,5 +46,5 @@ class FL_EXPORT Fl_GIF_Image : public Fl
  822. #endif
  823. //
  824. -// End of "$Id: Fl_GIF_Image.H 4288 2005-04-16 00:13:17Z mike $".
  825. +// End of "$Id: Fl_GIF_Image.H,v 1.1 2006-04-06 14:01:27 nikego Exp $".
  826. //
  827. diff -Nwrup -x.git fltk-1.1.9/FL/fltk_dfb_ex.h FLTK_1.x-DirectFB/FL/fltk_dfb_ex.h
  828. --- fltk-1.1.9/FL/fltk_dfb_ex.h 1969-12-31 19:00:00.000000000 -0500
  829. +++ FLTK_1.x-DirectFB/FL/fltk_dfb_ex.h 2009-11-28 15:48:05.853153701 -0500
  830. @@ -0,0 +1,129 @@
  831. +#ifndef __FLTK_DFB_EX_H__
  832. +#define __FLTK_DFB_EX_H__
  833. +
  834. +/************************************************************************
  835. + * External FLTK`s functions which available in DirectFB`s version of the library only.
  836. +*/
  837. +
  838. +/* create offscreen compatible with primary surface */
  839. +extern void* fl_create_offscreen(int w,int h);
  840. +
  841. +/* create ARGB offscreen*/
  842. +extern void* fl_create_offscreen_rgb(int w,int h);
  843. +
  844. +/* delete offscreen*/
  845. +extern void fl_delete_offscreen(void* surface);
  846. +
  847. +/* set offscreen as current drawing surface*/
  848. +extern void fl_begin_offscreen(void* surface );
  849. +
  850. +/* restore old drawing surface*/
  851. +extern void fl_end_offscreen();
  852. +
  853. +/* copy from offscreen to current surface*/
  854. +extern void fl_copy_offscreen(int _x,int _y,int _w,int _h,void* offscreen,int srcx,int srcy);
  855. +
  856. +/* bkcolor color is excluded when copying */
  857. +extern void fl_copy_offscreen_bk(int _x,int _y,int _w,int _h,void* offscreen,int srcx,int srcy,ulong bkcolor);
  858. +
  859. +/*
  860. + * filter and smooth functions.
  861. + * They draw good-looking image especially if your display has low resolution ( e.c.640x480 ).
  862. + */
  863. +
  864. +/* available masks for filtering
  865. + *
  866. + * 1 - 2 X 2 1 1
  867. + * 1 1
  868. + *
  869. + * 2 - 3 X 3 1 1 1
  870. + * 1 1 1
  871. + * 1 1 1
  872. + *
  873. + * 3 - 3 X 3 1 1 1
  874. + * 1 2 1
  875. + * 1 1 1
  876. + *
  877. + * 4 - 3 X 3 1 2 1
  878. + * 2 4 2
  879. + * 1 2 1
  880. + *
  881. + * 5 - 3 X 3 0 2 0
  882. + * 2 4 2
  883. + * 0 2 0
  884. + *
  885. + * 6 - 4 X 4 1 1 1 1
  886. + * 1 1 1 1
  887. + * 1 1 1 1
  888. + * 1 1 1 1
  889. + *
  890. + * 7 - 7 X 7 1 2 3 4 3 2 1
  891. + * 2 4 6 8 6 4 2
  892. + * 3 6 9 12 9 6 5
  893. + * 4 8 12 16 12 8 4
  894. + * 3 6 9 12 9 6 5
  895. + * 2 4 6 8 6 4 2
  896. + * 1 2 3 4 3 2 1
  897. + */
  898. +/* filter offscreen rectangle using mask */
  899. +extern void fl_filter_offscreen(void* offscreen,int x,int y,int w,int h,int mask);
  900. +
  901. +/* filter widget's rectangle*/
  902. +extern void fl_filter_widget(Fl_Widget *wdg, int mask );
  903. +
  904. +/* draw a smooth line */
  905. +extern void fl_line(double x1, double y1, double x2, double y2);
  906. +
  907. +/* draw a smooth edge.
  908. + * The egde is a line having only one smooth side ( left hand side ). */
  909. +extern void fl_edge(double x1, double y1, double x2, double y2);
  910. +
  911. +/* start drawing smooth lines */
  912. +extern void fl_begin_smooth_line();
  913. +
  914. +/* start drawing a closed sequence of smooth lines*/
  915. +extern void fl_begin_smooth_loop();
  916. +
  917. +/*
  918. + * start drawing of polygon with smooth edges
  919. + * list the points in clockwise direction
  920. + 1 2
  921. + *--->-----*
  922. + |######### \
  923. + |########## \
  924. + ^########### V
  925. + |############ \
  926. + |############# \
  927. + *-------<-------*
  928. + 0 3
  929. +*/
  930. +extern void fl_begin_smooth_polygon();
  931. +
  932. +/* set and get a mask which be used after fl_draw() function*/
  933. +extern void set_text_smooth(int);
  934. +extern int get_text_smooth();
  935. +
  936. +/* hide/show the cursor*/
  937. +extern void fl_show_cursor(int);
  938. +
  939. +
  940. +/*******************************************************************
  941. + * it's an example of using of smooth drawing
  942. + * Fl_Smooth_Clock class declaration
  943. + *
  944. + */
  945. +
  946. +#include <FL/Fl_Clock.H>
  947. +
  948. +class Fl_Smooth_Clock: public Fl_Clock{
  949. +public:
  950. + Fl_Smooth_Clock(int x,int y,int w,int h, const char *l = 0):Fl_Clock(x,y,w,h,l){};
  951. +protected:
  952. + void drawsmhands(Fl_Color fill, Fl_Color line);
  953. + virtual void draw();
  954. + void draw(int X, int Y, int W, int H);
  955. +};
  956. +
  957. +
  958. +/****************************************************************************/
  959. +#endif
  960. diff -Nwrup -x.git fltk-1.1.9/FL/Makefile FLTK_1.x-DirectFB/FL/Makefile
  961. --- fltk-1.1.9/FL/Makefile 1969-12-31 19:00:00.000000000 -0500
  962. +++ FLTK_1.x-DirectFB/FL/Makefile 2009-11-28 15:48:05.852153755 -0500
  963. @@ -0,0 +1,63 @@
  964. +#
  965. +# "$Id: Makefile.in 5745 2007-03-15 13:27:41Z mike $"
  966. +#
  967. +# Header makefile for the Fast Light Tool Kit (FLTK).
  968. +#
  969. +# Copyright 1998-2007 by Bill Spitzak and others.
  970. +#
  971. +# This library is free software; you can redistribute it and/or
  972. +# modify it under the terms of the GNU Library General Public
  973. +# License as published by the Free Software Foundation; either
  974. +# version 2 of the License, or (at your option) any later version.
  975. +#
  976. +# This library is distributed in the hope that it will be useful,
  977. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  978. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  979. +# Library General Public License for more details.
  980. +#
  981. +# You should have received a copy of the GNU Library General Public
  982. +# License along with this library; if not, write to the Free Software
  983. +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  984. +# USA.
  985. +#
  986. +# Please report all bugs and problems on the following page:
  987. +#
  988. +# http://www.fltk.org/str.php
  989. +#
  990. +
  991. +include ../makeinclude
  992. +
  993. +all:
  994. +
  995. +clean:
  996. +
  997. +depend:
  998. +
  999. +install:
  1000. + echo "Installing include files in $(DESTDIR)$(includedir)..."
  1001. + $(RMDIR) $(DESTDIR)$(includedir)/FL
  1002. + $(INSTALL_DIR) $(DESTDIR)$(includedir)/FL
  1003. + for file in *.[hrH]; do \
  1004. + $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/FL; \
  1005. + done
  1006. + cd $(DESTDIR)$(includedir)/FL;\
  1007. + for file in *.H; do\
  1008. + $(RM) "`basename $$file H`h";\
  1009. + $(LN) $$file "`basename $$file H`h";\
  1010. + done
  1011. + $(RM) $(DESTDIR)$(includedir)/FL/fl_file_chooser.H
  1012. + $(LN) Fl_File_Chooser.H $(DESTDIR)$(includedir)/FL/fl_file_chooser.H
  1013. + $(RM) $(DESTDIR)$(includedir)/FL/fl_file_chooser.h
  1014. + $(LN) Fl_File_Chooser.H $(DESTDIR)$(includedir)/FL/fl_file_chooser.h
  1015. + $(RM) $(DESTDIR)$(includedir)/Fl
  1016. + $(LN) FL $(DESTDIR)$(includedir)/Fl
  1017. +
  1018. +uninstall:
  1019. + echo "Uninstalling include files..."
  1020. + $(RMDIR) $(DESTDIR)$(includedir)/FL
  1021. + $(RM) $(DESTDIR)$(includedir)/Fl
  1022. +
  1023. +
  1024. +#
  1025. +# End of "$Id: Makefile.in 5745 2007-03-15 13:27:41Z mike $".
  1026. +#
  1027. diff -Nwrup -x.git fltk-1.1.9/FL/x.H FLTK_1.x-DirectFB/FL/x.H
  1028. --- fltk-1.1.9/FL/x.H 2006-07-18 07:23:20.000000000 -0400
  1029. +++ FLTK_1.x-DirectFB/FL/x.H 2009-11-28 15:48:05.855154687 -0500
  1030. @@ -33,12 +33,16 @@
  1031. #ifndef Fl_X_H
  1032. # define Fl_X_H
  1033. +#include <config.h>
  1034. +
  1035. # include "Enumerations.H"
  1036. # ifdef WIN32
  1037. # include "win32.H"
  1038. # elif defined(__APPLE__)
  1039. # include "mac.H"
  1040. +# elif defined(DIRECTFB)
  1041. +# include "DirectFB.H"
  1042. # else
  1043. # if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
  1044. # pragma set woff 3322
  1045. @@ -142,7 +146,6 @@ extern FL_EXPORT int fl_parse_color(cons
  1046. # endif
  1047. #endif
  1048. -
  1049. //
  1050. // End of "$Id: x.H 5262 2006-07-18 11:23:20Z matt $".
  1051. //
  1052. diff -Nwrup -x.git fltk-1.1.9/FL/xutils.h FLTK_1.x-DirectFB/FL/xutils.h
  1053. --- fltk-1.1.9/FL/xutils.h 1969-12-31 19:00:00.000000000 -0500
  1054. +++ FLTK_1.x-DirectFB/FL/xutils.h 2009-11-28 15:48:05.856153881 -0500
  1055. @@ -0,0 +1,963 @@
  1056. +//
  1057. +// "$Id xutils.h 4563 2006-03-06 23:03:34Z $"
  1058. +//
  1059. +// DirectFB-specific code for the Fast Light Tool Kit (FLTK).
  1060. +//
  1061. +// Copyright 1998-2005 by Bill Spitzak and others.
  1062. +//
  1063. +// Written by Nikita Egorov (NikeGo@gmail.com)
  1064. +// This library is free software; you can redistribute it and/or
  1065. +// modify it under the terms of the GNU Library General Public
  1066. +// License as published by the Free Software Foundation; either
  1067. +// version 2 of the License, or (at your option) any later version.
  1068. +//
  1069. +// This library is distributed in the hope that it will be useful,
  1070. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  1071. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1072. +// Library General Public License for more details.
  1073. +//
  1074. +// You should have received a copy of the GNU Library General Public
  1075. +// License along with this library; if not, write to the Free Software
  1076. +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  1077. +// USA.
  1078. +//
  1079. +// Please report all bugs and problems on the following page:
  1080. +//
  1081. +// http://www.fltk.org/str.php
  1082. +//
  1083. +
  1084. +#ifndef _XUTILS_H_
  1085. +#define _XUTILS_H_
  1086. +
  1087. +#include <stdio.h>
  1088. +#include <malloc.h>
  1089. +#include <directfb.h>
  1090. +#include <directfb_strings.h>
  1091. +#include <directfb_util.h>
  1092. +
  1093. +#include "Enumerations.H"
  1094. +
  1095. +#define Success 0 /* everything's okay */
  1096. +
  1097. +#if USE_ALLOCA
  1098. +/* alloca() is available, so use it for better performance */
  1099. +#define ALLOCA(size) alloca(size)
  1100. +#define FREEA(pmem)
  1101. +#else
  1102. +/* no alloca(), so use malloc()/free() instead */
  1103. +#define ALLOCA(size) Xmalloc(size)
  1104. +#define FREEA(pmem) Xfree(pmem)
  1105. +#endif
  1106. +
  1107. +/* malloc stuff */
  1108. +#if MALLOC_0_RETURNS_NULL
  1109. +/* for machines that do not return a valid pointer for malloc(0)*/
  1110. +# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
  1111. +# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
  1112. +# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
  1113. +#else
  1114. +# define Xmalloc(size) malloc((size))
  1115. +# define Xrealloc(ptr, size) realloc((ptr), (size))
  1116. +# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
  1117. +#endif
  1118. +
  1119. +#define Xfree(ptr) free((ptr))
  1120. +
  1121. +#define swap(a,b) do { a ^= b; b ^= a; a ^= b; } while (0)
  1122. +
  1123. +typedef struct surface_context {
  1124. + IDirectFBSurface* surface;
  1125. + DFBUpdates updates;
  1126. + surface_context* clip_mask;
  1127. + DFBRegion clip_region;
  1128. + struct {
  1129. + u8 r,g,b,a; // current color
  1130. + };
  1131. + struct {
  1132. + u32 dashmask; // An actual bitmask of the dash values
  1133. + u32 dashcount; // The number of bits defined in the dashmask
  1134. + u32 bit; // current bit
  1135. + };
  1136. +}*GC,*Surface;
  1137. +
  1138. +typedef uintptr_t XID;
  1139. +typedef XID Window;
  1140. +typedef XID Drawable;
  1141. +typedef XID Pixmap;
  1142. +typedef DFBPoint XPoint;
  1143. +typedef DFBPoint POINT;
  1144. +
  1145. +typedef DFBRectangle RECT;
  1146. +typedef DFBRectangle XRectangle;
  1147. +typedef DFBRegion* Region;
  1148. +typedef IDirectFBFont* XFont;
  1149. +typedef IDirectFBWindow* dfbWindow;
  1150. +
  1151. +typedef ulong Colormap;
  1152. +typedef IDirectFBDisplayLayer Display;
  1153. +
  1154. +typedef XID KeySym;
  1155. +
  1156. +// try to convert xid into a pointer
  1157. +#define ISGC(xid) ((xid)&~0xFFFF)?(GC)(xid):0
  1158. +
  1159. +#define PIXMAP(surf) (Pixmap)(surf)
  1160. +
  1161. +GC find_gc(XID xid);
  1162. +
  1163. +typedef struct POINT_f {
  1164. + double x;
  1165. + double y;
  1166. +} POINT_f_t;
  1167. +
  1168. +/* outline and filled arc and pie types*/
  1169. +#define ARC 0x0001 /* arc*/
  1170. +#define OUTLINE 0x0002
  1171. +#define ARCOUTLINE 0x0003 /* arc + outline*/
  1172. +#define PIE 0x0004 /* pie (filled)*/
  1173. +#define ELLIPSE 0x0008 /* ellipse outline*/
  1174. +#define ELLIPSEFILL 0x0010 /* ellipse filled*/
  1175. +
  1176. +/* set polygon fill routine*/
  1177. +#define EDGEPOLYFILL 1 /* edge table, malloc, qsort*/
  1178. +#define HAVEFLOAT 1
  1179. +
  1180. +/* Fill mode */
  1181. +#define FILL_SOLID 0
  1182. +#define FILL_STIPPLE 1
  1183. +#define FILL_OPAQUE_STIPPLE 2
  1184. +#define FILL_TILE 3
  1185. +
  1186. +#define MIN(a,b) ((a) < (b) ? (a) : (b))
  1187. +#define MAX(a,b) ((a) > (b) ? (a) : (b))
  1188. +
  1189. +#if 1
  1190. +# define MEMORY_TYPE DSCAPS_VIDEOONLY
  1191. +#else
  1192. +# define MEMORY_TYPE DSCAPS_SYSTEMONLY
  1193. +#endif
  1194. +
  1195. +void release_gc(GC gc);
  1196. +void release_window(dfbWindow win);
  1197. +
  1198. +#define __tolower(a) (((a) >= 'A' && ((a) <= 'Z') ? ((a)+('a'-'A')):(a)))
  1199. +#define __toupper(a) (((a) >= 'a' && ((a) <= 'z') ? ((a)-('a'-'A')):(a)))
  1200. +
  1201. +/*
  1202. + * Where to find fonts...
  1203. + */
  1204. +
  1205. +#define X11_FONT_DIR1 "/usr/fonts/truetype"
  1206. +#define X11_FONT_DIR2 "/usr/X11R6/lib/X11/fonts/TrueType"
  1207. +
  1208. +#define X11_RGBTXT "/usr/X11R6/lib/X11/rgb.txt"
  1209. +
  1210. +/* Changeable options*/
  1211. +#define USE_ALLOCA 1 /* set if system has alloca()*/
  1212. +#define MALLOC_0_RETURNS_NULL 0 /* not yet needed*/
  1213. +
  1214. +/* required settings*/
  1215. +#define NeedFunctionPrototypes 1 /* ANSI C*/
  1216. +#define XLIB_ILLEGAL_ACCESS 1 /* define real structures*/
  1217. +
  1218. +/* deal with _Xconst differences in X11 header files*/
  1219. +#ifndef XCONST
  1220. +#define XCONST _Xconst
  1221. +#endif
  1222. +
  1223. +
  1224. +#define None 0
  1225. +
  1226. +/*
  1227. + * cursor structure for DirectFB
  1228. + */
  1229. +
  1230. +typedef struct _cursor {
  1231. + Pixmap shape;
  1232. + int hot_x;
  1233. + int hot_y;
  1234. + Pixmap source;
  1235. + Pixmap mask;
  1236. +}*Cursor;
  1237. +
  1238. +/* Display classes used in opening the connection
  1239. + * Note that the statically allocated ones are even numbered and the
  1240. + * dynamically changeable ones are odd numbered */
  1241. +
  1242. +#define StaticGray 0
  1243. +#define GrayScale 1
  1244. +#define StaticColor 2
  1245. +#define PseudoColor 3
  1246. +#define TrueColor 4
  1247. +#define DirectColor 5
  1248. +
  1249. +#define LSBFirst 0
  1250. +#define MSBFirst 1
  1251. +
  1252. +/*
  1253. + * Visual structure; contains information about colormapping possible.
  1254. + */
  1255. +typedef struct {
  1256. + void *ext_data; /* hook for extension to hang data */
  1257. + int visualid; /* visual id of this visual */
  1258. + int c_class; /* C++ class of screen (monochrome, etc.) */
  1259. + unsigned long red_mask, green_mask, blue_mask; /* mask values */
  1260. + int bits_per_rgb; /* log base 2 of distinct color values */
  1261. + int map_entries; /* color map entries */
  1262. +} Visual;
  1263. +
  1264. +/*
  1265. + * Information used by the visual utility routines to find desired visual
  1266. + * type from the many visuals a display may support.
  1267. + */
  1268. +typedef struct {
  1269. + Visual *visual;
  1270. + int visualid;
  1271. + int screen;
  1272. + int depth;
  1273. + int c_class; /* C++ */
  1274. + unsigned long red_mask;
  1275. + unsigned long green_mask;
  1276. + unsigned long blue_mask;
  1277. + int colormap_size;
  1278. + int bits_per_rgb;
  1279. + int byte_order;
  1280. +///////////
  1281. + int bits_per_pixel;
  1282. + int bytes_per_pixel;
  1283. +} VisualInfo;
  1284. +
  1285. +
  1286. +#define Status int
  1287. +#define _Xconst const
  1288. +
  1289. +
  1290. +// create compatible surface system memory only;
  1291. +GC create_mem_gc( int w ,int h, int pf = -1 );
  1292. +Pixmap create_pixmap( int w ,int h, int pf = -1 );
  1293. +
  1294. +/*defines for unmodified (Xrm) Xlib routines...*/
  1295. +/*#define LockDisplay(dpy)
  1296. +#define UnlockDisplay(dpy)
  1297. +#define _XLockMutex(lock)
  1298. +#define _XUnlockMutex(lock)
  1299. +#define _XCreateMutex(lock)
  1300. +#define _XFreeMutex(lock)
  1301. +*/
  1302. +/* ImageFormat -- PutImage, GetImage */
  1303. +
  1304. +#define XYBitmap 0 /* depth 1, XYFormat */
  1305. +#define XYPixmap 1 /* depth == drawable depth */
  1306. +#define ZPixmap 2 /* depth == drawable depth */
  1307. +
  1308. +/*
  1309. + * Data structure for retrieving info about pixmap formats.
  1310. + */
  1311. +typedef struct {
  1312. + int depth;
  1313. + int bits_per_pixel;
  1314. + int scanline_pad;
  1315. +} XPixmapFormatValues;
  1316. +
  1317. +/*
  1318. + * Data structure for "image" data, used by image manipulation routines.
  1319. + */
  1320. +typedef struct _XImage {
  1321. + int width, height; /* size of image */
  1322. + int xoffset; /* number of pixels offset in X direction */
  1323. + int format; /* XYBitmap, XYPixmap, ZPixmap */
  1324. + char *data; /* pointer to image data */
  1325. + int byte_order; /* data byte order, LSBFirst, MSBFirst */
  1326. + int bitmap_unit; /* quant. of scanline 8, 16, 32 */
  1327. + int bitmap_bit_order; /* LSBFirst, MSBFirst */
  1328. + int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */
  1329. + int depth; /* depth of image */
  1330. + int bytes_per_line; /* accelarator to next line */
  1331. + int bits_per_pixel; /* bits per pixel (ZPixmap) */
  1332. + unsigned long red_mask; /* bits in z arrangment */
  1333. + unsigned long green_mask;
  1334. + unsigned long blue_mask;
  1335. + // XPointer obdata; /* hook for the object routines to hang on */
  1336. + struct funcs { /* image manipulation routines */
  1337. +#if 1 //NeedFunctionPrototypes
  1338. + struct _XImage *(*create_image)(
  1339. + Display* /* display */,
  1340. + Visual* /* visual */,
  1341. + unsigned int /* depth */,
  1342. + int /* format */,
  1343. + int /* offset */,
  1344. + char* /* data */,
  1345. + unsigned int /* width */,
  1346. + unsigned int /* height */,
  1347. + int /* bitmap_pad */,
  1348. + int /* bytes_per_line */);
  1349. + int (*destroy_image) (struct _XImage *);
  1350. + unsigned long (*get_pixel) (struct _XImage *,unsigned int, unsigned int);
  1351. + int (*put_pixel) (struct _XImage *,unsigned int, unsigned int, unsigned long);
  1352. + struct _XImage *(*sub_image)(struct _XImage *,unsigned int, unsigned int, unsigned int, unsigned int);
  1353. + int (*add_pixel) (struct _XImage *, long);
  1354. +#else
  1355. + struct _XImage *(*create_image)();
  1356. + int (*destroy_image)();
  1357. + unsigned long (*get_pixel)();
  1358. + int (*put_pixel)();
  1359. + struct _XImage *(*sub_image)();
  1360. + int (*add_pixel)();
  1361. +#endif
  1362. + } f;
  1363. +} XImage;
  1364. +
  1365. +/*
  1366. + * stubs..
  1367. + */
  1368. +
  1369. +char* XKeysymToString(KeySym keysym);
  1370. +
  1371. +int XBell(Display *display, int percent);
  1372. +
  1373. +int XMapWindow(Display* display, Window w);
  1374. +
  1375. +int XMapRaised(Display* display, Window w);
  1376. +
  1377. +int XUnmapWindow(Display* display, Window w);
  1378. +
  1379. +char* XGetDefault(Display* display, _Xconst char* program, _Xconst char*);
  1380. +
  1381. +#define RootWindow( d, s ) fl_window
  1382. +#define DefaultRootWindow( d ) fl_window
  1383. +#define AllPlanes ((unsigned long)~0L)
  1384. +
  1385. +int XQueryKeymap(Display* d, char s[32]);
  1386. +
  1387. +int XFlush(Display* display);
  1388. +
  1389. +int XKeysymToKeycode(Display* d, KeySym ks);
  1390. +
  1391. +/* Return values from XRectInRegion() */
  1392. +
  1393. +#define RectangleOut 0
  1394. +#define RectangleIn 1
  1395. +#define RectanglePart 2
  1396. +
  1397. +/*
  1398. + * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
  1399. + * value (x, y, width, height) was found in the parsed string.
  1400. + */
  1401. +#define NoValue 0x0000
  1402. +#define XValue 0x0001
  1403. +#define YValue 0x0002
  1404. +#define WidthValue 0x0004
  1405. +#define HeightValue 0x0008
  1406. +#define AllValues 0x000F
  1407. +#define XNegative 0x0010
  1408. +#define YNegative 0x0020
  1409. +
  1410. +#define AllocNone 0 /* create map with no entries */
  1411. +#define AllocAll 1 /* allocate entire map writeable */
  1412. +
  1413. +
  1414. +/*
  1415. + * Data structure used by color operations
  1416. + */
  1417. +typedef struct {
  1418. + long pixel;
  1419. + unsigned short red, green, blue;
  1420. + unsigned short alpha;
  1421. + char flags; /* do_red, do_green, do_blue */
  1422. + char pad;
  1423. +} XColor;
  1424. +
  1425. +/* Used internally for the colormap */
  1426. +
  1427. +#define GR_PIXELVAL int
  1428. +#define GR_COLOR int
  1429. +
  1430. +typedef struct {
  1431. + GR_PIXELVAL value;
  1432. + int ref;
  1433. + unsigned short r, g, b;
  1434. +} nxColorval;
  1435. +
  1436. +typedef struct _nxColormap {
  1437. + int id;
  1438. + int color_alloc;
  1439. + int cur_color;
  1440. + int saved_color;
  1441. + DFBColor colors[256];
  1442. + nxColorval *colorval;
  1443. + struct _nxColormap *next;
  1444. +} nxColormap;
  1445. +
  1446. +extern Pixmap clip_mask;
  1447. +/*
  1448. + *
  1449. + * Region and rectange functions
  1450. + *
  1451. + */
  1452. +int
  1453. +XCopyArea(Display *display,Drawable src,Drawable dest,GC gc,
  1454. + int src_x,int src_y,unsigned width,unsigned height,int dest_x,int dest_y);
  1455. +
  1456. +Region XRectangleRegion(int x, int y, int w, int h);
  1457. +
  1458. +Region XCreateRegion();
  1459. +
  1460. +int XDestroyRegion(Region r);
  1461. +
  1462. +int XRectInRegion(Region r,int x,int y,int w,int h);
  1463. +
  1464. +void XClipBox(Region r, XRectangle* rect);
  1465. +
  1466. +void XSetRegion(Display* display, GC gc, Region r, int set_clip=1);
  1467. +
  1468. +void XSetClipMask(Display* display, GC gc, Pixmap pixmap);
  1469. +
  1470. +int XIntersectRegion(Region r1, Region r2, Region newReg);
  1471. +
  1472. +int XSetClipOrigin(Display* display, GC gc, int clip_x_origin, int clip_y_origin);
  1473. +
  1474. +int XUnionRectWithRegion(XRectangle* rect, Region source, Region dest);
  1475. +
  1476. +int XUnionRectWithRegion( int x,int y,int w,int h, Region source, Region dest);
  1477. +
  1478. +int XParseGeometry(const char *parsestring, int *x, int *y, unsigned int *w, unsigned int *h);
  1479. +
  1480. +Status XParseColor(Display *display, Colormap colormap, const char *spec, XColor *exact_def_return);
  1481. +
  1482. +/*********************************************/
  1483. +void flip_updates( GC );
  1484. +
  1485. +void remove_updates( GC );
  1486. +
  1487. +void update_region( GC surface, DFBRegion* r );
  1488. +
  1489. +void update_region(GC surface,int x1,int y1,int x2,int y2);
  1490. +
  1491. +#define update_rect(s,x,y,w,h)\
  1492. + update_region((s),DFB_REGION_VALS_FROM_RECTANGLE_VALS((x),(y),(w),(h)));
  1493. +
  1494. +/*********************************************/
  1495. +extern int gr_fillmode;
  1496. +
  1497. +void XDrawLine(Display* display,Drawable d,GC gc,int x1,int y1,int x2,int y2);
  1498. +
  1499. +void XDrawLines(Display* display,Drawable d,GC gc,Region points,int npoints,int mode);
  1500. +
  1501. +void XDrawRectangle(Display* display,Drawable d,GC gc,int x,int y,int width,int height);
  1502. +
  1503. +void XFillRectangle(Display* display,Drawable d,GC gc,int x,int y,int width,int height);
  1504. +
  1505. +#define draw_line_i(x1,y1,x2,y2)\
  1506. + XDrawLine(fl_display,fl_window,fl_gc, (int)(x1+.5),(int)(y1+.5),(int)(x2+.5),(int)(y2+.5))
  1507. +
  1508. +#define draw_line_r(x1,y1,x2,y2)\
  1509. + draw_smooth_line(fl_gc,x1,y1,x2,y2)
  1510. +
  1511. +void FillPoly(Drawable d,GC gc,int count, POINT_f *pointtable );
  1512. +
  1513. +void Arc(GC gc, short x0, short y0, short rx, short ry, short ax, short ay, short bx, short by, int type);
  1514. +
  1515. +void ArcAngle(GC gc, int x,int y,int w,int h,double a1,double a2, int type );
  1516. +
  1517. +#ifdef SMOOTH_DRAWING
  1518. +/* experimental stuff */
  1519. +
  1520. +void SmoothPoly(GC gc, int count, POINT_f *pointtable);
  1521. +
  1522. +void draw_smooth_line(GC gc, double x1, double y1, double x2, double y2);
  1523. +
  1524. +void fl_filter_offscreen(GC offscreen, int x, int y, int w, int h, int );
  1525. +
  1526. +void drawrow(GC gc,int x1,int x2,int y);
  1527. +
  1528. +#endif /* SMOOTH_DRAWING */
  1529. +
  1530. +void set_dash_style(GC ctx, u32 mask, u32 count);
  1531. +
  1532. +void SetDashStyle( unsigned long mask);
  1533. +
  1534. +int SetClipRect (int x, int y, int w, int h);
  1535. +
  1536. +int SetClipRect (DFBRegion* r);
  1537. +
  1538. +/* _colormap.cxx*/
  1539. +nxColormap *_nxFindColormap(Colormap id);
  1540. +
  1541. +Colormap _nxDefaultColormap(Display* display);
  1542. +
  1543. +Colormap XCreateColormap(Display * display, Window w, Visual * visual, int alloc);
  1544. +
  1545. +inline Colormap XCreateColormap(Display *display ){
  1546. + return XCreateColormap( display , 0, 0, 0 );
  1547. +}
  1548. +
  1549. +GR_COLOR GrGetColorByName(char *colorname, int *retr, int *retg, int *retb);
  1550. +
  1551. +int get_rgb_color( int xcolor, uchar& r, uchar& g, uchar& b );
  1552. +
  1553. +int get_index_color(uchar r,uchar g,uchar b);
  1554. +
  1555. +int XAllocColor( Display* display, Colormap colormap, XColor* in_out);
  1556. +
  1557. +int XQueryColor( Display* display, Colormap colormap, XColor * def);
  1558. +
  1559. +int XQueryColors( Display* display, Colormap colormap, XColor * def_in,int ncolors);
  1560. +
  1561. +int XFreeColors( Display* display, Colormap colormap, unsigned long pixels[],int npixels, unsigned long planes);
  1562. +
  1563. +int XFlushColormap( Display* display, Colormap colormap );
  1564. +
  1565. +void _nxPixel2RGB(Display* display, unsigned long color,
  1566. + unsigned short *red, unsigned short *green, unsigned short *blue);
  1567. +
  1568. +/* _listfonts.cxx */
  1569. +extern char **_nxfontlist;
  1570. +
  1571. +extern int _nxfontcount;
  1572. +
  1573. +FILE* _nxLoadFontDir(char *str);
  1574. +
  1575. +void _nxSetDefaultFontDir(void);
  1576. +
  1577. +void _nxSetFontDir(char **directories, int ndirs);
  1578. +
  1579. +char** _nxGetFontDir(int *count);
  1580. +
  1581. +void _nxFreeFontDir(char **list);
  1582. +
  1583. +/* _loadfont.cxx*/
  1584. +char* _nxFindX11Font(const char *in_font);
  1585. +
  1586. +/* */
  1587. +char** XListFonts( Display* display, const char *pattern, int maxnames, int *actual_count_return);
  1588. +
  1589. +XFont XLoadFont( Display* display, const char *fname );
  1590. +
  1591. +void XDestroyWindow( Display* display , Window window );
  1592. +
  1593. +int XFreeFont( Display* d, XFont font);
  1594. +
  1595. +int XFreeFontNames(char **list);
  1596. +
  1597. +int XIconifyWindow(Display* d, Window w, void* v);
  1598. +
  1599. +/*
  1600. + * image functions
  1601. + */
  1602. +int XPutImage(Display* display, Drawable d, GC gc, XImage * image,
  1603. + int src_x, int src_y, int dest_x, int dest_y, unsigned int width,
  1604. + unsigned int height);
  1605. +
  1606. +XImage* XCreateImage(Display* display, Visual* visual, unsigned int depth,
  1607. + int format, int offset, char *data, unsigned int width,
  1608. + unsigned int height, int bitmap_pad, int bytes_per_line);
  1609. +
  1610. +XImage* XGetImage(Display* display, Drawable d, int x, int y,
  1611. + unsigned int width, unsigned int height,
  1612. + unsigned long plane_mask, int format);
  1613. +
  1614. +int XDestroyImage(XImage *image);
  1615. +
  1616. +Pixmap XCreateBitmapFromData(Display* display, Drawable d, const char *data,
  1617. + unsigned int width, unsigned int height);
  1618. +
  1619. +/*
  1620. + * cursors
  1621. + */
  1622. +
  1623. +void XFreeCursor( Display* display, Cursor xc );
  1624. +
  1625. +inline void XFreePixmap(Display* display, Pixmap p )
  1626. +{
  1627. + if (ISGC(p))
  1628. + release_gc( (GC)p );
  1629. +}
  1630. +
  1631. +int XSetForeground(Display* display, GC gc, int color_index);
  1632. +
  1633. +void XDefineCursor(Display* display, Window win, Cursor c);
  1634. +
  1635. +Cursor XCreatePixmapCursor( Display* display, Pixmap p, Pixmap m, XColor *col1, XColor *col2, unsigned hot_x, unsigned hot_y );
  1636. +
  1637. +Cursor XCreateFontCursor(Display *display, unsigned int shape);
  1638. +
  1639. +int XRecolorCursor(Display* display, Cursor cursor, XColor *fg_col, XColor *bg_col);
  1640. +
  1641. +/********************************************************************************/
  1642. +
  1643. +/*static inline int
  1644. +__sleep(int mssec){
  1645. + struct timespec rqtp,rmtp;
  1646. + rqtp.tv_sec = mssec / 1000;
  1647. + rqtp.tv_nsec = mssec * 1000000;
  1648. + nanosleep(&rqtp, &rmtp);
  1649. + return rmtp.tv_sec * 1000 + rmtp.tv_nsec / 1000000;
  1650. +}*/
  1651. +
  1652. +static const DirectFBPixelFormatNames(format_names);
  1653. +
  1654. +static inline const char* pixelformat_name( int format ) {
  1655. + int i;
  1656. + for (i=0; format_names[i].format != DSPF_UNKNOWN; i++) {
  1657. + if (format_names[i].format == (DFBSurfacePixelFormat)format)
  1658. + return format_names[i].name;
  1659. + }
  1660. + return "INVALID FORMAT";
  1661. +}
  1662. +
  1663. +void dump_surf_data(GC surf, int x, int y, int w, int h);
  1664. +
  1665. +/*****************************************************************
  1666. + * EVENT DEFINITIONS
  1667. + *****************************************************************/
  1668. +
  1669. +/* Input Event Masks. Used as event-mask window attribute and as arguments
  1670. + to Grab requests. Not to be confused with event names. */
  1671. +
  1672. +#define NoEventMask 0L
  1673. +#define KeyPressMask (1L<<0)
  1674. +#define KeyReleaseMask (1L<<1)
  1675. +#define ButtonPressMask (1L<<2)
  1676. +#define ButtonReleaseMask (1L<<3)
  1677. +#define EnterWindowMask (1L<<4)
  1678. +#define LeaveWindowMask (1L<<5)
  1679. +#define PointerMotionMask (1L<<6)
  1680. +#define PointerMotionHintMask (1L<<7)
  1681. +#define Button1MotionMask (1L<<8)
  1682. +#define Button2MotionMask (1L<<9)
  1683. +#define Button3MotionMask (1L<<10)
  1684. +#define Button4MotionMask (1L<<11)
  1685. +#define Button5MotionMask (1L<<12)
  1686. +#define ButtonMotionMask (1L<<13)
  1687. +#define KeymapStateMask (1L<<14)
  1688. +#define ExposureMask (1L<<15)
  1689. +#define VisibilityChangeMask (1L<<16)
  1690. +#define StructureNotifyMask (1L<<17)
  1691. +#define ResizeRedirectMask (1L<<18)
  1692. +#define SubstructureNotifyMask (1L<<19)
  1693. +#define SubstructureRedirectMask (1L<<20)
  1694. +#define FocusChangeMask (1L<<21)
  1695. +#define PropertyChangeMask (1L<<22)
  1696. +#define ColormapChangeMask (1L<<23)
  1697. +#define OwnerGrabButtonMask (1L<<24)
  1698. +
  1699. +/* Event names. Used in "type" field in XEvent structures. Not to be
  1700. +confused with event masks abo…