--- deliantra/Deliantra-Client/Client.xs 2007/12/28 15:40:07 1.249 +++ deliantra/Deliantra-Client/Client.xs 2008/04/10 14:35:50 1.258 @@ -48,11 +48,15 @@ #include -#if !(defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 15, 2)) -# define pango_layout_get_line_readonly pango_layout_get_line_readonly -# define pango_layout_get_lines_readonly pango_layout_get_lines_readonly -# define pango_layout_iter_get_line_readonly pango_layout_iter_get_line_readonly -# define pango_layout_iter_get_run_readonly pango_layout_iter_get_run_readonly +#ifndef PANGO_VERSION_CHECK +# define PANGO_VERSION_CHECK(a,b,c) 0 +#endif + +#if !PANGO_VERSION_CHECK (1, 15, 2) +# define pango_layout_get_line_readonly pango_layout_get_line +# define pango_layout_get_lines_readonly pango_layout_get_lines +# define pango_layout_iter_get_line_readonly pango_layout_iter_get_line +# define pango_layout_iter_get_run_readonly pango_layout_iter_get_run #endif #ifndef _WIN32 @@ -72,6 +76,9 @@ #define MIN_FONT_HEIGHT 10 +/* mask out modifiers we are not interested in */ +#define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) + #if 0 # define PARACHUTE SDL_INIT_NOPARACHUTE #else @@ -180,7 +187,7 @@ layout_update_font (DC__Layout self) { /* use a random scale factor to account for unknown descenders, 0.8 works - * reasonably well with bitstream vera + * reasonably well with dejavu/bistream fonts */ PangoFontDescription *font = self->font ? self->font : default_font; @@ -668,9 +675,10 @@ opengl_fontmap = pango_opengl_font_map_new (); pango_opengl_font_map_set_default_substitute ((PangoOpenGLFontMap *)opengl_fontmap, substitute_func, 0, 0); opengl_context = pango_opengl_font_map_create_context ((PangoOpenGLFontMap *)opengl_fontmap); -#if defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 15, 2) + /*pango_context_set_font_description (opengl_context, default_font);*/ +#if PANGO_VERSION_CHECK (1, 15, 2) pango_context_set_language (opengl_context, pango_language_from_string ("en")); - pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR); + /*pango_context_set_base_dir (opengl_context, PANGO_DIRECTION_WEAK_LTR);*/ #endif } @@ -765,6 +773,9 @@ int SDL_GetAppState () +int +SDL_GetModState () + void poll_events () PPCODE: @@ -783,8 +794,8 @@ case SDL_KEYUP: hv_store (hv, "state", 5, newSViv (ev.key.state), 0); hv_store (hv, "sym", 3, newSViv (ev.key.keysym.sym), 0); - hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod), 0); - hv_store (hv, "cmod", 4, newSViv (SDL_GetModState ()), 0); /* current mode */ + hv_store (hv, "mod", 3, newSViv (ev.key.keysym.mod & MOD_MASK), 0); + hv_store (hv, "cmod", 4, newSViv (SDL_GetModState () & MOD_MASK), 0); /* current mode */ hv_store (hv, "unicode", 7, newSViv (ev.key.keysym.unicode), 0); break; @@ -812,7 +823,7 @@ SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_EVENTMASK (SDL_MOUSEMOTION)); } - hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); + hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); hv_store (hv, "state", 5, newSViv (state), 0); hv_store (hv, "x", 1, newSViv (x), 0); hv_store (hv, "y", 1, newSViv (y), 0); @@ -823,7 +834,7 @@ case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: - hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); + hv_store (hv, "mod", 3, newSViv (SDL_GetModState () & MOD_MASK), 0); hv_store (hv, "button", 6, newSViv (ev.button.button), 0); hv_store (hv, "state", 5, newSViv (ev.button.state), 0); @@ -907,10 +918,12 @@ #endif } -void +int add_font (char *file) CODE: - FcConfigAppFontAddFile (0, (const FcChar8 *)file); + RETVAL = FcConfigAppFontAddFile (0, (const FcChar8 *)file); + OUTPUT: + RETVAL void load_image_inline (SV *image_) @@ -1314,13 +1327,13 @@ cursor_pos (DC::Layout self, int index) PPCODE: { - PangoRectangle strong_pos; - pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); + PangoRectangle pos; + pango_layout_get_cursor_pos (self->pl, index, &pos, 0); EXTEND (SP, 3); - PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); - PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); - PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); + PUSHs (sv_2mortal (newSViv (pos.x / PANGO_SCALE))); + PUSHs (sv_2mortal (newSViv (pos.y / PANGO_SCALE))); + PUSHs (sv_2mortal (newSViv (pos.height / PANGO_SCALE))); } void @@ -1330,7 +1343,7 @@ int line, x; pango_layout_index_to_line_x (self->pl, index, trailing, &line, &x); -#if !(defined (PANGO_VERSION_CHECK) && PANGO_VERSION_CHECK (1, 17, 3)) +#if !PANGO_VERSION_CHECK (1, 17, 3) /* pango bug: line is between 1..numlines, not 0..numlines-1 */ --line; #endif