ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.243 by root, Thu Dec 27 06:54:36 2007 UTC vs.
Revision 1.255 by root, Sun Jan 6 18:25:59 2008 UTC

46 46
47#include <glib/gmacros.h> 47#include <glib/gmacros.h>
48 48
49#include <pango/pango.h> 49#include <pango/pango.h>
50 50
51#ifndef PANGO_VERSION_CHECK
52# define PANGO_VERSION_CHECK(a,b,c) 0
53#endif
54
55#if !PANGO_VERSION_CHECK (1, 15, 2)
56# define pango_layout_get_line_readonly pango_layout_get_line
57# define pango_layout_get_lines_readonly pango_layout_get_lines
58# define pango_layout_iter_get_line_readonly pango_layout_iter_get_line
59# define pango_layout_iter_get_run_readonly pango_layout_iter_get_run
60#endif
61
51#ifndef _WIN32 62#ifndef _WIN32
52# include <sys/types.h> 63# include <sys/types.h>
53# include <sys/socket.h> 64# include <sys/socket.h>
54# include <netinet/in.h> 65# include <netinet/in.h>
55# include <netinet/tcp.h> 66# include <netinet/tcp.h>
62 73
63#define MAP_EXTEND_X 32 74#define MAP_EXTEND_X 32
64#define MAP_EXTEND_Y 512 75#define MAP_EXTEND_Y 512
65 76
66#define MIN_FONT_HEIGHT 10 77#define MIN_FONT_HEIGHT 10
78
79/* mask out modifiers we are not interested in */
80#define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META)
67 81
68#if 0 82#if 0
69# define PARACHUTE SDL_INIT_NOPARACHUTE 83# define PARACHUTE SDL_INIT_NOPARACHUTE
70#else 84#else
71# define PARACHUTE 0 85# define PARACHUTE 0
659 CODE: 673 CODE:
660{ 674{
661 opengl_fontmap = pango_opengl_font_map_new (); 675 opengl_fontmap = pango_opengl_font_map_new ();
662 pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); 676 pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0);
663 opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); 677 opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap);
678#if PANGO_VERSION_CHECK (1, 15, 2)
679 pango_context_set_language (opengl_context, pango_language_from_string ("en"));
680 /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/
681#endif
664} 682}
665 683
666char * 684char *
667SDL_GetError () 685SDL_GetError ()
668 686
770 { 788 {
771 case SDL_KEYDOWN: 789 case SDL_KEYDOWN:
772 case SDL_KEYUP: 790 case SDL_KEYUP:
773 hv_store (hv, "state", 5, newSViv (ev.key.state), 0); 791 hv_store (hv, "state", 5, newSViv (ev.key.state), 0);
774 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); 792 hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0);
775 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); 793 hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0);
776 hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */ 794 hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */
777 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); 795 hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0);
778 break; 796 break;
779 797
780 case SDL_ACTIVEEVENT: 798 case SDL_ACTIVEEVENT:
781 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0); 799 hv_store (hv, "gain", 4, newSViv (ev.active.gain), 0);
799 x = ev.motion.x; 817 x = ev.motion.x;
800 y = ev.motion.y; 818 y = ev.motion.y;
801 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); 819 SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION));
802 } 820 }
803 821
804 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 822 hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0);
805 hv_store (hv, "state", 5, newSViv (state), 0); 823 hv_store (hv, "state", 5, newSViv (state), 0);
806 hv_store (hv, "x", 1, newSViv (x), 0); 824 hv_store (hv, "x", 1, newSViv (x), 0);
807 hv_store (hv, "y", 1, newSViv (y), 0); 825 hv_store (hv, "y", 1, newSViv (y), 0);
808 hv_store (hv, "xrel", 4, newSViv (xrel), 0); 826 hv_store (hv, "xrel", 4, newSViv (xrel), 0);
809 hv_store (hv, "yrel", 4, newSViv (yrel), 0); 827 hv_store (hv, "yrel", 4, newSViv (yrel), 0);
810 } 828 }
811 break; 829 break;
812 830
813 case SDL_MOUSEBUTTONDOWN: 831 case SDL_MOUSEBUTTONDOWN:
814 case SDL_MOUSEBUTTONUP: 832 case SDL_MOUSEBUTTONUP:
815 hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); 833 hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0);
816 834
817 hv_store (hv, "button", 6, newSViv (ev.button.button), 0); 835 hv_store (hv, "button", 6, newSViv (ev.button.button), 0);
818 hv_store (hv, "state", 5, newSViv (ev.button.state), 0); 836 hv_store (hv, "state", 5, newSViv (ev.button.state), 0);
819 hv_store (hv, "x", 1, newSViv (ev.button.x), 0); 837 hv_store (hv, "x", 1, newSViv (ev.button.x), 0);
820 hv_store (hv, "y", 1, newSViv (ev.button.y), 0); 838 hv_store (hv, "y", 1, newSViv (ev.button.y), 0);
1165{ 1183{
1166 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 1184 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
1167 1185
1168 do 1186 do
1169 { 1187 {
1170 PangoLayoutRun *run = pango_layout_iter_get_run (iter); 1188 PangoLayoutRun *run = pango_layout_iter_get_run_readonly (iter);
1171 1189
1172 if (run && shape_attr_p (run)) 1190 if (run && shape_attr_p (run))
1173 { 1191 {
1174 PangoRectangle extents; 1192 PangoRectangle extents;
1175 pango_layout_iter_get_run_extents (iter, 0, &extents); 1193 pango_layout_iter_get_run_extents (iter, 0, &extents);
1279int 1297int
1280descent (DC::Layout self) 1298descent (DC::Layout self)
1281 CODE: 1299 CODE:
1282{ 1300{
1283 PangoRectangle rect; 1301 PangoRectangle rect;
1284 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 1302 PangoLayoutLine *line = pango_layout_get_line_readonly (self->pl, 0);
1285 pango_layout_line_get_pixel_extents (line, 0, &rect); 1303 pango_layout_line_get_pixel_extents (line, 0, &rect);
1286 RETVAL = PANGO_DESCENT (rect); 1304 RETVAL = PANGO_DESCENT (rect);
1287} 1305}
1288 OUTPUT: 1306 OUTPUT:
1289 RETVAL 1307 RETVAL
1301 1319
1302void 1320void
1303cursor_pos (DC::Layout self, int index) 1321cursor_pos (DC::Layout self, int index)
1304 PPCODE: 1322 PPCODE:
1305{ 1323{
1306 PangoRectangle strong_pos; 1324 PangoRectangle pos;
1307 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1325 pango_layout_get_cursor_pos (self->pl, index, &pos, 0);
1308 1326
1309 EXTEND (SP, 3); 1327 EXTEND (SP, 3);
1310 PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); 1328 PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE)));
1311 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1329 PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE)));
1312 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1330 PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE)));
1313} 1331}
1314 1332
1315void 1333void
1316index_to_line_x (DC::Layout self, int index, int trailing = 0) 1334index_to_line_x (DC::Layout self, int index, int trailing = 0)
1317 PPCODE: 1335 PPCODE:
1318{ 1336{
1319 int line, x; 1337 int line, x;
1320 1338
1321 pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); 1339 pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x);
1340#if !PANGO_VERSION_CHECK (1, 17, 3)
1322 /* pango bug: line is between 1..numlines, not 0..numlines-1 */ 1341 /* pango bug: line is between 1..numlines, not 0..numlines-1 */
1323 1342 --line;
1343#endif
1324 EXTEND (SP, 2); 1344 EXTEND (SP, 2);
1325 PUSHs (sv_2mortal (newSViv (line - 1))); 1345 PUSHs (sv_2mortal (newSViv (line)));
1326 PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE))); 1346 PUSHs (sv_2mortal (newSViv (x / PANGO_SCALE)));
1327} 1347}
1328 1348
1329void 1349void
1330line_x_to_index (DC::Layout self, int line, int x) 1350line_x_to_index (DC::Layout self, int line, int x)
1334 int index, trailing; 1354 int index, trailing;
1335 1355
1336 if (line < 0) 1356 if (line < 0)
1337 XSRETURN_EMPTY; 1357 XSRETURN_EMPTY;
1338 1358
1339 if (!(lp = pango_layout_get_line (self->pl, line))) 1359 if (!(lp = pango_layout_get_line_readonly (self->pl, line)))
1340 XSRETURN_EMPTY; /* do better */ 1360 XSRETURN_EMPTY; /* do better */
1341 1361
1342 pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing); 1362 pango_layout_line_x_to_index (lp, x * PANGO_SCALE, &index, &trailing);
1343 1363
1344 EXTEND (SP, 2); 1364 EXTEND (SP, 2);
2846void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) 2866void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column)
2847 CODE: 2867 CODE:
2848 if (gl.SeparableFilter2D) 2868 if (gl.SeparableFilter2D)
2849 gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); 2869 gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column);
2850 2870
2851void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) 2871void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data = 0)
2852 2872
2853void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) 2873void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border)
2854 2874
2855void glDrawPixels (int width, int height, int format, int type, char *pixels) 2875void glDrawPixels (int width, int height, int format, int type, char *pixels)
2856 2876

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines