From 2feab9d52c1956d9c5c3d2752caa7685b5d00990 Mon Sep 17 00:00:00 2001 From: Franck Charlet Date: Thu, 14 May 2009 13:49:36 +0000 Subject: [PATCH] - Issue #160 should be fixed now. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@804 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- English.lproj/InfoPlist.strings | Bin 630 -> 650 bytes Grafx2.xcodeproj/project.pbxproj | 20 +++++++++++++++++ Grafx2.xcodeproj/xx.pbxuser | 4 ++-- Grafx2.xcodeproj/xx.perspective | 36 +++++++++++++++---------------- SDLMain.m | 16 ++++++++++++++ filesel.c | 1 + global.h | 10 +++++++++ input.c | 9 ++++++++ keyboard.c | 10 ++++++++- 9 files changed, 85 insertions(+), 21 deletions(-) diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings index 78ad12bddc682b04bd9f8d5dc659f070541f7573..1538ff2196f68e438f14b2b269de2e76daff3e58 100644 GIT binary patch delta 39 icmeyy(#5(Vn~_tO!HB^C2rVaPG4`VHj3;X{`2qm6>IiQD delta 19 ZcmeBT{l>B(n{hHXlhNemj8Q PBXSmartGroupTreeModuleColumnWidthsKey - 418 + 275 PBXSmartGroupTreeModuleColumnsKey_v4 @@ -481,7 +481,7 @@ PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 506}, {418, 592}} + {{0, 0}, {275, 583}} PBXTopSmartGroupGIDs @@ -491,19 +491,19 @@ GeometryConfiguration Frame - {{0, 0}, {435, 610}} + {{0, 0}, {292, 601}} GroupTreeTableConfiguration MainColumn - 418 + 275 RubberWindowFrame - 225 -383 1092 651 0 0 1024 746 + 2 -15 944 642 0 0 1024 746 Module PBXSmartGroupTreeModule Proportion - 435pt + 292pt Dock @@ -535,9 +535,9 @@ GeometryConfiguration Frame - {{0, 0}, {652, 0}} + {{0, 0}, {647, 0}} RubberWindowFrame - 225 -383 1092 651 0 0 1024 746 + 2 -15 944 642 0 0 1024 746 Module PBXNavigatorGroup @@ -546,14 +546,14 @@ Proportion - 605pt + 596pt Tabs ContentConfiguration PBXBuildLogShowsTranscriptDefaultKey - {{0, 5}, {652, 573}} + {{0, 5}, {647, 564}} PBXProjectModuleGUID XCMainBuildResultsModuleGUID PBXProjectModuleLabel @@ -566,9 +566,9 @@ GeometryConfiguration Frame - {{10, 27}, {652, 578}} + {{10, 27}, {647, 569}} RubberWindowFrame - 225 -383 1092 651 0 0 1024 746 + 2 -15 944 642 0 0 1024 746 Module PBXBuildResultsModule @@ -630,7 +630,7 @@ Proportion - 652pt + 647pt Name @@ -648,14 +648,14 @@ TableOfContents - F5F7346C0F94B3DD003FC65B + F5AA406F0FBC418100B7577C 1CA23EE50692099D00951B8B - F5F7346D0F94B3DD003FC65B + F5AA40700FBC418100B7577C F5A33EC20EC89C3000F8052D - F5F7346E0F94B3DD003FC65B + F5AA40710FBC418100B7577C XCMainBuildResultsModuleGUID 1CA23EE80692099D00951B8B - F5F7346F0F94B3DD003FC65B + F5AA40720FBC418100B7577C ToolbarConfiguration xcode.toolbar.config.buildAndRun @@ -829,7 +829,7 @@ /Users/xx/Grafx2/Grafx2.xcodeproj WindowString - 225 -383 1092 651 0 0 1024 746 + 2 -15 944 642 0 0 1024 746 WindowTools diff --git a/SDLMain.m b/SDLMain.m index 05b39448..5274d96c 100644 --- a/SDLMain.m +++ b/SDLMain.m @@ -76,6 +76,20 @@ static NSString *getApplicationName(void) event.type = SDL_QUIT; SDL_PushEvent(&event); } +/* override NSApplication:sendEvent, to keep Cocoa from beeping on + non-command keystrokes */ +- (void)sendEvent:(NSEvent *)anEvent { + if (NSKeyDown == [anEvent type] || NSKeyUp == [anEvent type]) { + if ([anEvent modifierFlags] & NSCommandKeyMask) + { + SDL_SetModState(SDL_GetModState() | KMOD_META); + [super sendEvent: anEvent]; + } + } else + { + [super sendEvent: anEvent]; + } +} @end /* The main class of the application, the application's delegate */ @@ -297,6 +311,8 @@ static void CustomApplicationMain (int argc, char **argv) [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()]; #endif + setenv("SDL_ENABLEAPPEVENTS", "1", 1); + /* Hand off to main application code */ gCalledAppMainline = TRUE; status = SDL_main (gArgc, gArgv); diff --git a/filesel.c b/filesel.c index 7b59a79a..bacaa853 100644 --- a/filesel.c +++ b/filesel.c @@ -1,5 +1,6 @@ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2009 Franck Charlet Copyright 2008 Peter Gordon Copyright 2008 Yves Rizoud Copyright 2007 Adrien Destugues diff --git a/global.h b/global.h index cd6e312d..d4ed4517 100644 --- a/global.h +++ b/global.h @@ -102,12 +102,22 @@ GFX2_GLOBAL dword Key_ANSI; #ifdef MOD_ALT #undef MOD_ALT #endif + +#if defined(__macosx__) +#ifdef MOD_META + #undef MOD_META +#endif +#endif + /// Key modifier for SHIFT key. Used as mask in ::Key, for example. #define MOD_SHIFT 0x1000 /// Key modifier for CONTROL key. Used as mask in ::Key, for example. #define MOD_CTRL 0x2000 /// Key modifier for ALT key. Used as mask in ::Key, for example. #define MOD_ALT 0x4000 +#if defined(__macosx__) +#define MOD_META 0x8000 +#endif /// Boolean set to true when the OS/window manager requests the application to close. ie: [X] button GFX2_GLOBAL byte Quit_is_required; diff --git a/input.c b/input.c index ee2db87b..9335cb42 100644 --- a/input.c +++ b/input.c @@ -1,5 +1,6 @@ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2009 Franck Charlet Copyright 2007 Adrien Destugues Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) @@ -364,6 +365,14 @@ int Handle_key_release(SDL_KeyboardEvent event) case SDLK_MODE: modifier=MOD_ALT; break; + +#if defined(__macosx__) + case SDLK_RMETA: + case SDLK_LMETA: + modifier=MOD_META; + break; +#endif + default: modifier=0; } diff --git a/keyboard.c b/keyboard.c index 1ce195a5..20d371fd 100644 --- a/keyboard.c +++ b/keyboard.c @@ -1,5 +1,6 @@ /* Grafx2 - The Ultimate 256-color bitmap paint program + Copyright 2009 Franck Charlet Copyright 2008 Yves Rizoud Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) @@ -318,6 +319,11 @@ word Key_modifiers(SDLMod mod) if (mod & (KMOD_ALT|KMOD_MODE)) modifiers|=MOD_ALT; +#if defined(__macosx__) + if (mod & (KMOD_META)) + modifiers|=MOD_META; +#endif + return modifiers; } @@ -325,11 +331,12 @@ word Keysym_to_keycode(SDL_keysym keysym) { word key_code = 0; word mod; - + // On ignore shift, alt et control isolés. if (keysym.sym == SDLK_RSHIFT || keysym.sym == SDLK_LSHIFT || keysym.sym == SDLK_RCTRL || keysym.sym == SDLK_LCTRL || keysym.sym == SDLK_RALT || keysym.sym == SDLK_LALT || + keysym.sym == SDLK_RMETA || keysym.sym == SDLK_LMETA || keysym.sym == SDLK_MODE) // AltGr return 0; @@ -346,6 +353,7 @@ word Keysym_to_keycode(SDL_keysym keysym) // is buggy: if you release a modifier key, the following keys (when they repeat) // still name the original modifiers. mod=Key_modifiers(SDL_GetModState()); + // SDL_GetModState() seems to get the right up-to-date info. key_code |= mod; return key_code;