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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines