Large bundle of OS X tweaks by Eric P. (basis of the 10.9-compatible

pre-release made in Dec. 2013):
 * Fix OS X 10.9 issue of current directory set by Finder
   to something else than folder where app bundle resides.
 * Some Mac OS X build / project changes & updates.
 * Adjustments to Mac OS X fontconfig config file, to avoid warnings
   and make things more robust.
 * Updates to some #include's to catch up with newer library revisions.
 * Tweaks to pixel read/write on Apple.
 * Introduction of 'intprt_t' casting to avoid warnings on x64.
 * Some additional debugging output.
 * Logging stderr & stdout to /tmp/tuxpaint.log
Untested (I don't have a Mac!)
This commit is contained in:
William Kendrick 2014-03-19 23:39:17 +00:00
parent e5b2182c0a
commit e990b48de7
14 changed files with 982 additions and 817 deletions

View file

@ -74,9 +74,27 @@ $Id$
Produced by Eric Poncet <http://www.linguasoft.com/> Produced by Eric Poncet <http://www.linguasoft.com/>
Commissioned by Harvey Ginter <harveyginter@gmail.com> Commissioned by Harvey Ginter <harveyginter@gmail.com>
* Fix OS X 10.9 issue of current directory set by Finder
to something else than folder where app bundle resides.
* Customization support for Mac OS X (automatic, under XCode) * Customization support for Mac OS X (automatic, under XCode)
and Windows (manual). and Windows (manual).
* Some Mac OS X build / project changes & updates.
* Adjustments to Mac OS X fontconfig config file, to avoid warnings
and make things more robust.
* Updates to some #include's to catch up with newer library revisions.
* Tweaks to pixel read/write on Apple.
* Introduction of 'intprt_t' casting to avoid warnings on x64.
* Some additional debugging output.
* Logging stderr & stdout to /tmp/tuxpaint.log
* Accessibility Improvements: * Accessibility Improvements:
--------------------------- ---------------------------
* Added a mouse accessibility mode to avoid the need to drag the mouse. * Added a mouse accessibility mode to avoid the need to drag the mouse.

View file

@ -74,8 +74,7 @@ This library will already have been built and installed by MacPorts, but will no
% tar xzf fontconfig*.tar.gz % tar xzf fontconfig*.tar.gz
% cd fontconfig* % cd fontconfig*
% sudo port deactivate fontconfig % sudo port deactivate fontconfig
% ./configure --prefix=/Users/Shared/tuxpaint --enable-static --disable-shared % ./configure --prefix=/Users/Shared/tuxpaint --enable-static --disable-shared --disable-docs --with-confdir="/Library/Application Support/TuxPaint/fontconfig/fonts" --with-cache-dir="/Library/Application Support/TuxPaint/fontconfig/cache" CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib
% --disable-docs --with-confdir="/Library/Application Support/TuxPaint/fontconfig/fonts" --with-cache-dir="/Library/Application Support/TuxPaint/fontconfig/cache" CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib
% sudo make install % sudo make install
% sudo port activate fontconfig % sudo port activate fontconfig
@ -102,6 +101,7 @@ MacPorts only installs the dynamic libraries for Pango. We need to reconfigure
% cd pango* % cd pango*
% sudo port deactivate pango % sudo port deactivate pango
% ./configure --prefix=/Users/Shared/tuxpaint --enable-static CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib --with-included-modules=yes --with-dynamic-modules=no --disable-shared % ./configure --prefix=/Users/Shared/tuxpaint --enable-static CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib --with-included-modules=yes --with-dynamic-modules=no --disable-shared
//EP pas de "make" ?
% sudo make install % sudo make install
% sudo find . -name "*.a" -exec cp {} /Users/Shared/tuxpaint/lib/ \; % sudo find . -name "*.a" -exec cp {} /Users/Shared/tuxpaint/lib/ \;
% sudo port activate pango % sudo port activate pango
@ -116,6 +116,7 @@ Assuming you place the sources in /Users/Shared/tuxpaint/src/libsvg, you can con
% cd /Users/Shared/tuxpaint/src/libsvg % cd /Users/Shared/tuxpaint/src/libsvg
% ./autogen.sh % ./autogen.sh
% ./configure --prefix=/Users/Shared/tuxpaint LIBSVG_CFLAGS=-I/usr/include LIBSVG_LIBS=-L/usr/lib --disable-shared % ./configure --prefix=/Users/Shared/tuxpaint LIBSVG_CFLAGS=-I/usr/include LIBSVG_LIBS=-L/usr/lib --disable-shared
//EP pas de "make" ?
% make install % make install
SVG Cairo: SVG Cairo:

View file

@ -131,7 +131,7 @@ static NSString *getApplicationName(void)
mainBundle = [NSBundle mainBundle]; mainBundle = [NSBundle mainBundle];
path = [mainBundle pathForResource:@"data" ofType:nil]; path = [mainBundle pathForResource:@"data" ofType:nil];
[path getCString:(macosx.dataPath)]; [path getCString:(macosx.dataPath) maxLength:sizeof(macosx.dataPath) encoding:NSUTF8StringEncoding]; //EP added maxLength: and encoding: to avoid deprecation warning for 10.6
} }
-(void) preferencesPath; -(void) preferencesPath;
@ -139,10 +139,11 @@ static NSString *getApplicationName(void)
NSString *path; NSString *path;
path = [@"~/Library/Application Support/TuxPaint" stringByExpandingTildeInPath]; path = [@"~/Library/Application Support/TuxPaint" stringByExpandingTildeInPath];
[path getCString:(macosx.preferencesPath)]; [path getCString:(macosx.preferencesPath) maxLength:sizeof(macosx.preferencesPath) encoding:NSUTF8StringEncoding]; //EP added maxLength: and encoding: to avoid deprecation warning for 10.6
path = @"/Library/Application Support/TuxPaint"; path = @"/Library/Application Support/TuxPaint";
[path getCString:(macosx.globalPreferencesPath)]; [path getCString:(macosx.globalPreferencesPath) maxLength:sizeof(macosx.globalPreferencesPath) encoding:NSUTF8StringEncoding]; //EP added maxLength: and encoding: to avoid deprecation warning for 10.6
} }
-(void) fontsPath; -(void) fontsPath;
@ -150,7 +151,7 @@ static NSString *getApplicationName(void)
NSString *path; NSString *path;
path = [@"~/Library/Fonts" stringByExpandingTildeInPath]; path = [@"~/Library/Fonts" stringByExpandingTildeInPath];
[path getCString:(macosx.fontsPath)]; [path getCString:(macosx.fontsPath) maxLength:sizeof(macosx.fontsPath) encoding:NSUTF8StringEncoding]; //EP added maxLength: and encoding: to avoid deprecation warning for 10.6
} }
@end @end
@ -330,7 +331,7 @@ static NSString *getApplicationName(void)
if ([menuItem hasSubmenu]) if ([menuItem hasSubmenu])
[self fixMenu:[menuItem submenu] withAppName:appName]; [self fixMenu:[menuItem submenu] withAppName:appName];
} }
[aMenu sizeToFit]; //EP commented line to avoid deprecation warning for 10.6: [aMenu sizeToFit];
} }
#else #else
@ -488,7 +489,8 @@ static void CustomApplicationMain (argc, argv)
NSString *arguments = [NSString stringWithCString:(macosx.globalPreferencesPath)]; NSString *arguments = [NSString stringWithCString:(macosx.globalPreferencesPath)];
char command[4096]; char command[4096];
sprintf(command, "\"%s\" \"%s\"", [executable cString], [arguments cString]); //EP commented to avoid deprecation warning for 10.6: sprintf(command, "\"%s\" \"%s\"", [executable cString], [arguments cString]);
sprintf(command, "\"%@\" \"%@\"", executable, arguments);
int result = system(command); int result = system(command);
@ -520,7 +522,7 @@ static void CustomApplicationMain (argc, argv)
char *arguments[] = { "/Library/Application Support/TuxPaint", NULL }; char *arguments[] = { "/Library/Application Support/TuxPaint", NULL };
FILE *communicationsPipe = NULL; FILE *communicationsPipe = NULL;
strcpy(executable, [fcInstallerPath cString]); strcpy(executable, [fcInstallerPath cStringUsingEncoding:NSUTF8StringEncoding]); //EP replaced cString by cStringUsingEncoding: to avoid deprecation warning for 10.6
flags = kAuthorizationFlagDefaults; flags = kAuthorizationFlagDefaults;
status = AuthorizationExecuteWithPrivileges(authorizationRef, executable, flags, arguments, &communicationsPipe); status = AuthorizationExecuteWithPrivileges(authorizationRef, executable, flags, arguments, &communicationsPipe);
@ -547,7 +549,7 @@ static void CustomApplicationMain (argc, argv)
- (void) setupFontconfig - (void) setupFontconfig
{ {
/* Tell Fontconfig to use font configuration file in application bundle */ /* Tell Fontconfig to use font configuration file in application bundle */
setenv ("FONTCONFIG_PATH", [[[NSBundle mainBundle] resourcePath] cString], 1); setenv ("FONTCONFIG_PATH", [[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:NSUTF8StringEncoding], 1); //EP replaced cString by cStringUsingEncoding: to avoid deprecation warning for 10.6
/* Install font configuration file */ /* Install font configuration file */
/* /*

File diff suppressed because it is too large Load diff

View file

@ -19,17 +19,27 @@
--> -->
<!-- Font directory list configured on Sun Sep 14 17:12:54 PDT 2003 --> <!-- Font directory list configured on Sun Sep 14 17:12:54 PDT 2003 -->
<!--
//EP
//commented out paths that prevented Inuktitut from rendering
-->
<dir>/Library/Fonts</dir> <dir>/Library/Fonts</dir>
<dir>/Network/Library/Fonts</dir> <dir>/Network/Library/Fonts</dir>
<dir>/System/Library/Fonts</dir> <!--dir>/System/Library/Fonts</dir-->
<dir>/usr/X11R6/lib/X11/fonts/Type1</dir> <dir>/usr/X11R6/lib/X11/fonts/Type1</dir>
<dir>/usr/X11R6/lib/X11/fonts/TTF</dir> <dir>/usr/X11R6/lib/X11/fonts/TTF</dir>
<dir>/usr/share/fonts</dir> <dir>/usr/share/fonts</dir>
<dir>~/Library/Fonts</dir> <dir>~/Library/Fonts</dir>
<dir>~/.fonts</dir> <dir>~/.fonts</dir>
<!--
//EP
//<cache> was ignored and every program init was slow
//replaced it by <cachedir> which reenabled the cache font and sped up further program inits
<cache>~/.fontconfig</cache> <cache>~/.fontconfig</cache>
-->
<cachedir>~/.fontconfig</cachedir>
<!-- <!--
Enable sub-pixel rendering Enable sub-pixel rendering
<match target="font"> <match target="font">
@ -84,6 +94,10 @@
<!-- <!--
Serif faces Serif faces
--> -->
<!--
//EP
//this generated Fontconfig warning: line XXX: Having multiple <family> in <alias> isn't supported and may not work as expected
//fixed by splitting alias so as to get only one family per alias
<alias> <alias>
<family>Times</family> <family>Times</family>
<family>Times New Roman</family> <family>Times New Roman</family>
@ -95,9 +109,47 @@
<family>Baekmuk Batang</family> <family>Baekmuk Batang</family>
<default><family>serif</family></default> <default><family>serif</family></default>
</alias> </alias>
-->
<alias>
<family>Times</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Times New Roman</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Nimbus Roman No9 L</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Luxi Serif</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Kochi Mincho</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>AR PL SungtiL GB</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>AR PL Mingti2L Big5</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Baekmuk Batang</family>
<default><family>serif</family></default>
</alias>
<!-- <!--
Sans-serif faces Sans-serif faces
--> -->
<!--
//EP
//this generated Fontconfig warning: line XXX: Having multiple <family> in <alias> isn't supported and may not work as expected
//fixed by splitting alias so as to get only one family per alias
<alias> <alias>
<family>Lucida Grande</family> <family>Lucida Grande</family>
<family>Geneva</family> <family>Geneva</family>
@ -114,9 +166,67 @@
<family>SimSun</family> <family>SimSun</family>
<default><family>sans-serif</family></default> <default><family>sans-serif</family></default>
</alias> </alias>
-->
<alias>
<family>Lucida Grande</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Geneva</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Helvetica</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Arial</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Verdana</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Nimbus Sans L</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Luxi Sans</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Osaka</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Kochi Gothic</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>AR PL KaitiM GB</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>AR PL KaitiM Big5</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Baekmuk Dotum</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>SimSun</family>
<default><family>sans-serif</family></default>
</alias>
<!-- <!--
Monospace faces Monospace faces
--> -->
<!--
//EP
//this generated Fontconfig warning: line XXX: Having multiple <family> in <alias> isn't supported and may not work as expected
//fixed by splitting alias so as to get only one family per alias
<alias> <alias>
<family>Monaco</family> <family>Monaco</family>
<family>Courier</family> <family>Courier</family>
@ -127,6 +237,36 @@
<family>NSimSun</family> <family>NSimSun</family>
<default><family>monospace</family></default> <default><family>monospace</family></default>
</alias> </alias>
-->
<alias>
<family>Monaco</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Courier</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Courier New</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Andale Mono</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Luxi Mono</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Nimbus Mono L</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>NSimSun</family>
<default><family>monospace</family></default>
</alias>
<!-- <!--
If the font still has no generic name, add sans-serif If the font still has no generic name, add sans-serif
--> -->

View file

@ -142,7 +142,12 @@ static void do_alien_pixel(void * ptr, int which ATTRIBUTE_UNUSED,
SDL_GetRGB(api->getpixel(canvas,x, y), canvas->format, &temp[0], &temp[1], &temp[2]); SDL_GetRGB(api->getpixel(canvas,x, y), canvas->format, &temp[0], &temp[1], &temp[2]);
for (k =0;k<3;k++){ for (k =0;k<3;k++){
temp2[k] = clamp(0,127.5 * (1.0 + sin (((temp[k] / 127.5 - 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)),255); //EP temp2[k] = clamp(0,127.5 * (1.0 + sin (((temp[k] / 127.5 - 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)),255);
temp2[k] = clamp(0.0,
127.5 * (
1.0 + sin (((temp[k] / 127.5 - 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)
),
255.0);
} }
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2])); api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2]));

View file

@ -107,13 +107,13 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
char fname[512]; char fname[512];
TuxPaint_Font *font; TuxPaint_Font *font;
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str); snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
/* printf("Loading font: %s (locale is: %s)\n", fname, (locale ? locale : "NULL")); */ /* */printf("Loading font: %s (locale is: %s)\n", fname, (locale ? locale : "NULL")); /**/ //EP
if (locale && strstr(fname, "locale") && !all_locale_fonts) if (locale && strstr(fname, "locale") && !all_locale_fonts)
{ {
char fname_check[512]; char fname_check[512];
/* We're (probably) loading from our locale fonts folder; ONLY load our locale's font */ /* We're (probably) loading from our locale fonts folder; ONLY load our locale's font */
snprintf(fname_check, sizeof fname_check, "%s/%s.ttf", dir, locale); snprintf(fname_check, sizeof fname_check, "%s/%s.ttf", dir, locale);
/* printf("checking vs \"%s\" vs \"%s\"\n", fname_check, fname); */ /* */printf("checking vs \"%s\" vs \"%s\"\n", fname_check, fname); /**/ //EP
if (strcmp(fname, fname_check) == 0) if (strcmp(fname, fname_check) == 0)
font = TuxPaint_Font_OpenFont("", fname, text_sizes[text_size]); font = TuxPaint_Font_OpenFont("", fname, text_sizes[text_size]);
else else
@ -136,7 +136,7 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
family, style); family, style);
printf("success: tpf: 0x%x tpf->ttf_font: 0x%x\n", printf("success: tpf: 0x%x tpf->ttf_font: 0x%x\n",
(unsigned int) font, (unsigned int) font->ttf_font); (unsigned int)(intptr_t) font, (unsigned int)(intptr_t) font->ttf_font); //EP added (intptr_t) to avoid warning on x64
#endif #endif
// These fonts crash Tux Paint via a library bug. // These fonts crash Tux Paint via a library bug.

View file

@ -259,15 +259,24 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
{ {
printf("TuxPaint_Font_CloseFont step 1 (%p)\n", tpf); //EP
if (!tpf) return; //EP
#ifndef NO_SDLPANGO #ifndef NO_SDLPANGO
printf("TuxPaint_Font_CloseFont step 2 (%p, %d)\n", tpf->pango_context, tpf->typ); //EP
if (tpf->typ == FONT_TYPE_PANGO) if (tpf->typ == FONT_TYPE_PANGO)
if (tpf->pango_context) //EP
{ {
#ifndef __APPLE__ //EP added ifdef because SDLPango_FreeContext sometimes crashed with "pointer being freed was not allocated"
SDLPango_FreeContext(tpf->pango_context); SDLPango_FreeContext(tpf->pango_context);
#endif
tpf->pango_context = NULL; tpf->pango_context = NULL;
} }
#endif #endif
printf("TuxPaint_Font_CloseFont step 3 (%p, %d)\n", tpf->ttf_font, tpf->typ); //EP
if (tpf->typ == FONT_TYPE_TTF) if (tpf->typ == FONT_TYPE_TTF)
if (tpf->ttf_font) //EP
{ {
TTF_CloseFont(tpf->ttf_font); TTF_CloseFont(tpf->ttf_font);
tpf->ttf_font = NULL; tpf->ttf_font = NULL;
@ -956,6 +965,8 @@ static void loadfonts(SDL_Surface * screen, const char *const dir)
status_t result; status_t result;
result = find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); result = find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
loadfonts(screen, buffer); loadfonts(screen, buffer);
result = find_directory(B_COMMON_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
loadfonts(screen, buffer);
result = find_directory(B_USER_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); result = find_directory(B_USER_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
loadfonts(screen, buffer); loadfonts(screen, buffer);
#elif defined(__APPLE__) #elif defined(__APPLE__)
@ -1286,7 +1297,7 @@ TuxPaint_Font *getfonthandle(int desire)
} }
else else
{ {
#ifdef DBEUG #ifdef DEBUG //EP fixed typo: replaced DBEUG with DEBUG
printf("fi->filename is NULL\n"); printf("fi->filename is NULL\n");
fflush(stdout); fflush(stdout);
#endif #endif
@ -1297,7 +1308,8 @@ TuxPaint_Font *getfonthandle(int desire)
if (fi->handle) if (fi->handle)
{ {
#ifdef DEBUG #ifdef DEBUG
printf("fi->handle was set (0x%x)\n", (int) fi->handle); printf("fi->handle was set (0x%x)\n", (int)(intptr_t) fi->handle); //EP added (intptr_t) to avoid warning on x64
fflush(stdout); fflush(stdout);
#endif #endif
return fi->handle; return fi->handle;

View file

@ -730,9 +730,12 @@ static int set_current_language(const char *restrict loc)
/* First set the locale according to the environment, then try to overwrite with loc, /* First set the locale according to the environment, then try to overwrite with loc,
after that, ctype_utf8() call will test the compatibility with utf8 and try to load after that, ctype_utf8() call will test the compatibility with utf8 and try to load
a different locale if the resulting one is not compatible. */ a different locale if the resulting one is not compatible. */
printf ("Locale BEFORE is: %s\n", setlocale(LC_ALL,NULL));//EP
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
setlocale(LC_ALL, loc); setlocale(LC_ALL, loc);
ctype_utf8(); ctype_utf8();
printf ("Locale AFTER is: %s\n", setlocale(LC_ALL,NULL));//EP
bindtextdomain("tuxpaint", LOCALEDIR); bindtextdomain("tuxpaint", LOCALEDIR);
/* Old version of glibc does not have bind_textdomain_codeset() */ /* Old version of glibc does not have bind_textdomain_codeset() */
@ -841,7 +844,7 @@ int setup_i18n(const char *restrict lang, const char *restrict locale)
if(lang) if(lang)
locale = language_to_locale(lang); locale = language_to_locale(lang);
patch_i18n(locale); //EP
return set_current_language(locale); return set_current_language(locale);
} }

View file

@ -484,7 +484,7 @@ static int charmap_add(CHARMAP* cm, int section, char* seq, const wchar_t* unico
/* For now, we only utilize one-character flags */ /* For now, we only utilize one-character flags */
if(strlen(flag) > 1) { if(strlen(flag) > 1) {
fprintf(stderr, "%04X: Multi-character flag, truncated.\n", (int)unicode); fprintf(stderr, "%04X: Multi-character flag, truncated.\n", (int)(intptr_t)unicode); //EP added (intptr_t) to avoid warning on x64
} }
return sm_add(&cm->sections[section], seq, unicode, flag[0]); return sm_add(&cm->sections[section], seq, unicode, flag[0]);

View file

@ -308,7 +308,7 @@ const char* SurfacePrint( SDL_Surface *surface, int showDialog )
// run printing // run printing
printOperation = [ NSPrintOperation printOperationWithView:printView printInfo:printInfo ]; printOperation = [ NSPrintOperation printOperationWithView:printView printInfo:printInfo ];
[ printOperation setShowPanels:showDialog ]; [ printOperation setShowsPrintPanel:showDialog ]; //EP replaced setShowPanels by setShowsPrintPanel
macosx.cocoaKeystrokes = 1; macosx.cocoaKeystrokes = 1;
delegate = [ [ [ ModalDelegate alloc ] init ] autorelease ]; delegate = [ [ [ ModalDelegate alloc ] init ] autorelease ];

View file

@ -1,3 +1,4 @@
#include "patch.h" //EP
#include "onscreen_keyboard.h" #include "onscreen_keyboard.h"
//#define DEBUG_OSK_COMPOSEMAP //#define DEBUG_OSK_COMPOSEMAP

View file

@ -13,6 +13,7 @@
#include <ctype.h> #include <ctype.h>
#include <stdint.h> #include <stdint.h>
#include "../src/parse.h" #include "../src/parse.h"
#include "debug.h"
const char PARSE_YES[] = "yes"; const char PARSE_YES[] = "yes";
const char PARSE_NO[] = "no"; const char PARSE_NO[] = "no";
@ -189,7 +190,9 @@ void parse_one_option(struct cfginfo *restrict tmpcfg, const char *str, const ch
char *dupecheck; char *dupecheck;
const struct cfg *cfg; const struct cfg *cfg;
//printf("parsing: <%s> <%s>\n",str,arg); #ifdef DEBUG
printf("parsing %s: <%s> <%s>\n", src, str, opt);
#endif
if(isdigit(*str)) if(isdigit(*str))
{ {

View file

@ -181,6 +181,7 @@ static scaleparams scaletable[] = {
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#include <libgen.h> //EP added this include for basename()
/* On Linux, we can use 'wordexp()' to expand env. vars. in settings /* On Linux, we can use 'wordexp()' to expand env. vars. in settings
pulled from config. files */ pulled from config. files */
@ -255,6 +256,7 @@ char *strcasestr(const char *haystack, const char *needle)
#endif #endif
#ifdef DEBUG #ifdef DEBUG
#undef gettext //EP to avoid warning on following line
#define gettext(String) debug_gettext(String) #define gettext(String) debug_gettext(String)
#endif #endif
@ -448,7 +450,7 @@ static void mtw(wchar_t * wtok, char * tok)
#else #else
#include <librsvg/rsvg.h> #include <librsvg/rsvg.h>
#include <librsvg/rsvg-cairo.h> //#include <librsvg/rsvg-cairo.h> //EP to avoid warning "Including <librsvg/rsvg-cairo.h> directly is deprecated."
/* #include "rsvg.h" */ /* #include "rsvg.h" */
/* #include "rsvg-cairo.h" */ /* #include "rsvg-cairo.h" */
#if !defined(RSVG_H) || !defined(RSVG_CAIRO_H) #if !defined(RSVG_H) || !defined(RSVG_CAIRO_H)
@ -463,6 +465,7 @@ static void mtw(wchar_t * wtok, char * tok)
#endif #endif
#include <zlib.h> //EP added for PNG upgrade from 1.2 to 1.5
#define PNG_INTERNAL #define PNG_INTERNAL
#include <png.h> #include <png.h>
#define FNAME_EXTENSION ".png" #define FNAME_EXTENSION ".png"
@ -507,6 +510,8 @@ static void mtw(wchar_t * wtok, char * tok)
#include "compiler.h" #include "compiler.h"
//EP added #ifndef __APPLE__ because macros are buggy (shifted by 1 byte), plus the function exists in SDL
#ifndef __APPLE__
#if VIDEO_BPP==32 #if VIDEO_BPP==32
#ifdef __GNUC__ #ifdef __GNUC__
#define SDL_GetRGBA(p,f,rp,gp,bp,ap) ({ \ #define SDL_GetRGBA(p,f,rp,gp,bp,ap) ({ \
@ -540,6 +545,7 @@ static void mtw(wchar_t * wtok, char * tok)
(((b) & 0xffu) << 0) \ (((b) & 0xffu) << 0) \
) )
#endif #endif
#endif
//#define fmemopen_alternative */ /* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */ //#define fmemopen_alternative */ /* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */
@ -4677,11 +4683,11 @@ static void mainloop(void)
{ {
if (((unsigned char *) event.user.data1)[0] == '=') if (((unsigned char *) event.user.data1)[0] == '=')
{ {
draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1 + 1, 1, (int)event.user.data2); draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1 + 1, 1, (int)(intptr_t)event.user.data2); //EP added (intptr_t) to avoid warning on x64
} }
else else
{ {
draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1, 0, (int)event.user.data2); draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1, 0, (int)(intptr_t)event.user.data2); //EP added (intptr_t) to avoid warning on x64
} }
} }
else else
@ -4700,10 +4706,10 @@ static void mainloop(void)
if (event.user.data1 != NULL) if (event.user.data1 != NULL)
{ {
if ((int) event.user.data1 == cur_stamp[stamp_group]) /* Don't play old stamp's sound... */ if ((int)(intptr_t) event.user.data1 == cur_stamp[stamp_group]) /* Don't play old stamp's sound... */ //EP added (intptr_t) to avoid warning on x64
{ {
if (!mute && stamp_data[stamp_group][(int) event.user.data1]->sdesc != NULL) if (!mute && stamp_data[stamp_group][(int)(intptr_t) event.user.data1]->sdesc != NULL) //EP added (intptr_t) to avoid warning on x64
Mix_PlayChannel(2, stamp_data[stamp_group][(int) event.user.data1]->sdesc, Mix_PlayChannel(2, stamp_data[stamp_group][(int)(intptr_t) event.user.data1]->sdesc, //EP added (intptr_t) to avoid warning on x64
0); 0);
} }
} }
@ -5977,7 +5983,7 @@ static void tint_surface(SDL_Surface * tmp_surf, SDL_Surface * surf_ptr)
width * height, &hue_range); width * height, &hue_range);
#ifdef DEBUG #ifdef DEBUG
printf("key_color_ptr = %d\n", (int) key_color_ptr); printf("key_color_ptr = %d\n", (int)(intptr_t) key_color_ptr); //EP added (intptr_t) to avoid warning on x64
#endif #endif
if (key_color_ptr) if (key_color_ptr)
@ -9309,6 +9315,22 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h)
one_minus_y = 1.0 - fraction_y; one_minus_y = 1.0 - fraction_y;
#if VIDEO_BPP==32 #if VIDEO_BPP==32
{ //EP added local block to avoid warning "Passing arg 3 from incompatible pointer type" of section below block
Uint8 r, g, b, a;
SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format,
&r, &g, &b, &a);
r1 = (float)r; g1=(float)g; b1 = (float)b; a1 = (float)a;
SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format,
&r, &g, &b, &a);
r2 = (float)r; g2=(float)g; b2 = (float)b; a2 = (float)a;
SDL_GetRGBA(getpixel(src, floor_x, ceil_y), src->format,
&r, &g, &b, &a);
r3 = (float)r; g3=(float)g; b3 = (float)b; a3 = (float)a;
SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format,
&r, &g, &b, &a);
r4 = (float)r; g4=(float)g; b4 = (float)b; a4 = (float)a;
}
/*
SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format, SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format,
&r1, &g1, &b1, &a1); &r1, &g1, &b1, &a1);
SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format, SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format,
@ -9317,6 +9339,7 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h)
&r3, &g3, &b3, &a3); &r3, &g3, &b3, &a3);
SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format, SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format,
&r4, &g4, &b4, &a4); &r4, &g4, &b4, &a4);
*/
#else #else
{ {
Uint8 r, g, b, a; Uint8 r, g, b, a;
@ -10517,7 +10540,7 @@ static void playstampdesc(int chan)
playsound_event.type = SDL_USEREVENT; playsound_event.type = SDL_USEREVENT;
playsound_event.user.code = USEREVENT_PLAYDESCSOUND; playsound_event.user.code = USEREVENT_PLAYDESCSOUND;
playsound_event.user.data1 = (void *) cur_stamp[stamp_group]; playsound_event.user.data1 = (void *)(intptr_t) cur_stamp[stamp_group]; //EP added (intptr_t) to avoid warning on x64
SDL_PushEvent(&playsound_event); SDL_PushEvent(&playsound_event);
} }
@ -11421,6 +11444,7 @@ static void load_current(void)
if (file_id[0] != '\0') if (file_id[0] != '\0')
{ {
start_label_node=NULL; start_label_node=NULL;
current_label_node=NULL; current_label_node=NULL;
first_label_node_in_redo_stack=NULL; first_label_node_in_redo_stack=NULL;
@ -12173,18 +12197,21 @@ static void cleanup(void)
if (medium_font != NULL) if (medium_font != NULL)
{ {
printf("cleanup: medium font\n"); //EP
TuxPaint_Font_CloseFont(medium_font); TuxPaint_Font_CloseFont(medium_font);
medium_font = NULL; medium_font = NULL;
} }
if (small_font != NULL) if (small_font != NULL)
{ {
printf("cleanup: small font\n"); //EP
TuxPaint_Font_CloseFont(small_font); TuxPaint_Font_CloseFont(small_font);
small_font = NULL; small_font = NULL;
} }
if (large_font != NULL) if (large_font != NULL)
{ {
printf("cleanup: large font\n"); //EP
TuxPaint_Font_CloseFont(large_font); TuxPaint_Font_CloseFont(large_font);
large_font = NULL; large_font = NULL;
} }
@ -12313,17 +12340,21 @@ static void cleanup(void)
SDL_Quit(); SDL_Quit();
/* Call this once only, at exit */ /* Call this once only, at exit */
//EP now deprecated
/*
#if !defined(NOSVG) && !defined(OLD_SVG) #if !defined(NOSVG) && !defined(OLD_SVG)
#ifdef DEBUG #ifdef DEBUG
printf("rsvg_term()\n"); fflush(stdout); printf("rsvg_term()\n"); fflush(stdout);
#endif #endif
rsvg_term(); rsvg_term();
#endif #endif
*/
} }
static void free_surface(SDL_Surface ** surface_array) static void free_surface(SDL_Surface ** surface_array)
{ {
if (surface_array) //EP added this line to avoid app crash
if (*surface_array) if (*surface_array)
{ {
SDL_FreeSurface(*surface_array); SDL_FreeSurface(*surface_array);
@ -12336,6 +12367,7 @@ static void free_surface_array(SDL_Surface * surface_array[], int count)
{ {
int i; int i;
if (surface_array) //EP added this line to avoid app crash
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
{ {
free_surface(&surface_array[i]); free_surface(&surface_array[i]);
@ -12962,7 +12994,7 @@ static void do_png_embed_data(png_structp png_ptr)
/* Starter foreground */ /* Starter foreground */
if (img_starter) if (img_starter)
{ {
printf("Saving starter... %d\n", (int) img_starter); printf("Saving starter... %d\n", (int)(intptr_t) img_starter); //EP added (intptr_t) to avoid warning on x64
sbk_pixs = malloc(img_starter->h * img_starter->w * 4); sbk_pixs = malloc(img_starter->h * img_starter->w * 4);
compressedLen = compressBound(img_starter->h * img_starter->w * 4); compressedLen = compressBound(img_starter->h * img_starter->w * 4);
@ -16145,7 +16177,8 @@ static void do_render_cur_text(int do_blit)
{ {
#if defined(_FRIBIDI_H) || defined(FRIBIDI_H) #if defined(_FRIBIDI_H) || defined(FRIBIDI_H)
//FriBidiCharType baseDir = FRIBIDI_TYPE_LTR; //FriBidiCharType baseDir = FRIBIDI_TYPE_LTR;
FriBidiCharType baseDir = FRIBIDI_TYPE_WL; /* Per: Shai Ayal <shaiay@gmail.com>, 2009-01-14 */ //FriBidiCharType baseDir = FRIBIDI_TYPE_WL; /* Per: Shai Ayal <shaiay@gmail.com>, 2009-01-14 */
FriBidiParType baseDir = FRIBIDI_TYPE_WL; //EP to avoid warning on types in now commented line above
FriBidiChar *unicodeIn, *unicodeOut; FriBidiChar *unicodeIn, *unicodeOut;
unsigned int i; unsigned int i;
@ -16500,7 +16533,7 @@ static void control_drawtext_timer(Uint32 interval, const char *const text, Uint
drawtext_event.type = SDL_USEREVENT; drawtext_event.type = SDL_USEREVENT;
drawtext_event.user.code = USEREVENT_TEXT_UPDATE; drawtext_event.user.code = USEREVENT_TEXT_UPDATE;
drawtext_event.user.data1 = (void *) text; drawtext_event.user.data1 = (void *) text;
drawtext_event.user.data2 = (void *) ((int) locale_text); drawtext_event.user.data2 = (void *) (intptr_t)((int) locale_text); //EP added (intptr_t) to avoid warning on x64
/* Add new timer */ /* Add new timer */
@ -17831,36 +17864,37 @@ static void load_magic_plugins(void)
SDL_LoadFunction(magic_handle[num_plugin_files], funcname); SDL_LoadFunction(magic_handle[num_plugin_files], funcname);
#ifdef DEBUG #ifdef DEBUG
//EP added (intptr_t) to avoid warning on x64 on all lines below
printf("get_tool_count = 0x%x\n", printf("get_tool_count = 0x%x\n",
(int) magic_funcs[num_plugin_files].get_tool_count); (int)(intptr_t) magic_funcs[num_plugin_files].get_tool_count);
printf("get_name = 0x%x\n", printf("get_name = 0x%x\n",
(int) magic_funcs[num_plugin_files].get_name); (int)(intptr_t) magic_funcs[num_plugin_files].get_name);
printf("get_icon = 0x%x\n", printf("get_icon = 0x%x\n",
(int) magic_funcs[num_plugin_files].get_icon); (int)(intptr_t) magic_funcs[num_plugin_files].get_icon);
printf("get_description = 0x%x\n", printf("get_description = 0x%x\n",
(int) magic_funcs[num_plugin_files].get_description); (int)(intptr_t) magic_funcs[num_plugin_files].get_description);
printf("requires_colors = 0x%x\n", printf("requires_colors = 0x%x\n",
(int) magic_funcs[num_plugin_files].requires_colors); (int)(intptr_t) magic_funcs[num_plugin_files].requires_colors);
printf("modes = 0x%x\n", printf("modes = 0x%x\n",
(int) magic_funcs[num_plugin_files].modes); (int)(intptr_t) magic_funcs[num_plugin_files].modes);
printf("set_color = 0x%x\n", printf("set_color = 0x%x\n",
(int) magic_funcs[num_plugin_files].set_color); (int)(intptr_t) magic_funcs[num_plugin_files].set_color);
printf("init = 0x%x\n", printf("init = 0x%x\n",
(int) magic_funcs[num_plugin_files].init); (int)(intptr_t) magic_funcs[num_plugin_files].init);
printf("api_version = 0x%x\n", printf("api_version = 0x%x\n",
(int) magic_funcs[num_plugin_files].api_version); (int)(intptr_t) magic_funcs[num_plugin_files].api_version);
printf("shutdown = 0x%x\n", printf("shutdown = 0x%x\n",
(int) magic_funcs[num_plugin_files].shutdown); (int)(intptr_t) magic_funcs[num_plugin_files].shutdown);
printf("click = 0x%x\n", printf("click = 0x%x\n",
(int) magic_funcs[num_plugin_files].click); (int)(intptr_t) magic_funcs[num_plugin_files].click);
printf("drag = 0x%x\n", printf("drag = 0x%x\n",
(int) magic_funcs[num_plugin_files].drag); (int)(intptr_t) magic_funcs[num_plugin_files].drag);
printf("release = 0x%x\n", printf("release = 0x%x\n",
(int) magic_funcs[num_plugin_files].release); (int)(intptr_t) magic_funcs[num_plugin_files].release);
printf("switchin = 0x%x\n", printf("switchin = 0x%x\n",
(int) magic_funcs[num_plugin_files].switchin); (int)(intptr_t) magic_funcs[num_plugin_files].switchin);
printf("switchout = 0x%x\n", printf("switchout = 0x%x\n",
(int) magic_funcs[num_plugin_files].switchout); (int)(intptr_t) magic_funcs[num_plugin_files].switchout);
#endif #endif
err = 0; err = 0;
@ -21594,6 +21628,14 @@ static void setup_config(char *argv[])
parse_argv_options(&tmpcfg_cmd, argv); parse_argv_options(&tmpcfg_cmd, argv);
#if defined(__APPLE__) //EP added this conditional section for Mac to allow for a config in the current directory, that supersedes sys and user configs
/* Mac OS X: Use a "tuxpaint.cfg" file in the current folder */
struct cfginfo tmpcfg_curdir;
memset(&tmpcfg_curdir, '\0', sizeof tmpcfg_curdir);
parse_file_options(&tmpcfg_curdir, "./tuxpaint.cfg");
tmpcfg_merge(&tmpcfg_curdir, &tmpcfg_cmd);
#endif
/* Set default options: */ /* Set default options: */
#ifndef _WIN32 #ifndef _WIN32
@ -21648,7 +21690,11 @@ static void setup_config(char *argv[])
#if defined(__APPLE__) //EP added this conditional section for Mac
tmpcfg_merge(&tmpcfg_usr, &tmpcfg_curdir);
#else
tmpcfg_merge(&tmpcfg_usr, &tmpcfg_cmd); tmpcfg_merge(&tmpcfg_usr, &tmpcfg_cmd);
#endif
if (tmpcfg_usr.parsertmp_sysconfig != PARSE_NO) if (tmpcfg_usr.parsertmp_sysconfig != PARSE_NO)
{ {
@ -21657,6 +21703,10 @@ static void setup_config(char *argv[])
#ifdef _WIN32 #ifdef _WIN32
// global config file in the application directory // global config file in the application directory
parse_file_options(&tmpcfg_sys, "tuxpaint.cfg"); parse_file_options(&tmpcfg_sys, "tuxpaint.cfg");
#elif defined(__APPLE__) //EP added this conditional section for Mac to fix folder&extension inconsistency with Tux Paint Config application)
/* Mac OS X: Use a "tuxpaint.cfg" file in the *global* Tux Paint application support folder */
snprintf(str, sizeof(str), "%s/tuxpaint.cfg", macosx.globalPreferencesPath);
parse_file_options(&tmpcfg_sys, str);
#else #else
// normally /etc/tuxpaint/tuxpaint.conf // normally /etc/tuxpaint/tuxpaint.conf
parse_file_options(&tmpcfg_sys, CONFDIR "tuxpaint.conf"); parse_file_options(&tmpcfg_sys, CONFDIR "tuxpaint.conf");
@ -22029,7 +22079,11 @@ static void setup_config(char *argv[])
static void chdir_to_binary(char *argv0) static void chdir_to_binary(char *argv0)
{ {
#if defined(__BEOS__) || defined(WIN32) char curdir[256]; //EP added this block to print out of current directory
getcwd(curdir, sizeof(curdir));
printf("Binary Path: %s\nCurrent directory at launchtime: %s\n", argv0, curdir);
#if defined(__BEOS__) || defined(WIN32) || defined(__APPLE__) //EP added __APPLE__
/* if run from gui, like OpenTracker in BeOS or Explorer in Windows, /* if run from gui, like OpenTracker in BeOS or Explorer in Windows,
find path from which binary was run and change dir to it find path from which binary was run and change dir to it
so all files will be local :) */ so all files will be local :) */
@ -22044,6 +22098,16 @@ static void chdir_to_binary(char *argv0)
char *app_path = strdup(argv0); char *app_path = strdup(argv0);
char *slash = strrchr(app_path, '/'); char *slash = strrchr(app_path, '/');
#if defined(__APPLE__) //EP added to fix 10.9 issue of current directory set by Finder to something else than folder where app bundle resides
// typical path of app's binary on Mac OS : /Applications/Tux Paint.app/Contents/MacOS/Tux Paint
int levels = 3; // we need to back up 3 levels
while ((levels-- > 0) && (slash))
{
*slash = '\0'; // this overwrites the \0 at end of string
slash = strrchr(app_path, '/'); // so we can carry on our back-pedaling...
}
#endif
if (!slash) if (!slash)
{ {
slash = strrchr(app_path, '\\'); slash = strrchr(app_path, '\\');
@ -22054,6 +22118,8 @@ static void chdir_to_binary(char *argv0)
chdir(app_path); chdir(app_path);
} }
free(app_path); free(app_path);
getcwd(curdir, sizeof(curdir));
printf("New current directory for runtime: %s\n", curdir);
} }
#else #else
(void)argv0; (void)argv0;
@ -23265,12 +23331,15 @@ static void setup(void)
#endif #endif
/* Call this once */ /* Call this once */
//EP now deprecated
/*
#if !defined(NOSVG) && !defined(OLD_SVG) #if !defined(NOSVG) && !defined(OLD_SVG)
#ifdef DEBUG #ifdef DEBUG
printf("rsvg_init()\n"); fflush(stdout); printf("rsvg_init()\n"); fflush(stdout);
#endif #endif
rsvg_init(); rsvg_init();
#endif #endif
*/
} }
@ -23394,6 +23463,19 @@ int main(int argc, char *argv[])
// do not add code (slowness) here unless required for scanning fonts // do not add code (slowness) here unless required for scanning fonts
progname = argv[0]; progname = argv[0];
#if defined(DEBUG) && defined(__APPLE__) //EP added block to log messages
freopen("/tmp/tuxpaint.log", "w", stdout); // redirect stdout to a file
dup2(fileno(stdout), fileno(stderr)); // redirect stderr to stdout
setvbuf(stdout, NULL, _IONBF, 0); // we don't want buffering to avoid de-sync'ing stdout and stderr
setvbuf(stderr, NULL, _IONBF, 0); // we don't want buffering to avoid de-sync'ing stdout and stderr
char logTime[100];
time_t t = time(NULL);
strftime(logTime, sizeof(logTime), "%A %d/%m/%Y %H:%M:%S", localtime(&t));
printf("Tux Paint log - %s\n", logTime);
#endif
chdir_to_binary(argv[0]); chdir_to_binary(argv[0]);
setup_config(argv); setup_config(argv);
@ -23490,6 +23572,8 @@ static int trash(char * path) {
debug("Can't get basename! Deleting instead."); debug("Can't get basename! Deleting instead.");
return(unlink(path)); return(unlink(path));
} }
printf("trash: basename=%s", basename(path)); //EP
strcpy(fname, basename(path)); strcpy(fname, basename(path));
if (!file_exists(path)) { if (!file_exists(path)) {