Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 90305 Details for
Bug 211359
Apple+Q doesn't quit an SWT app, nor does menu selection of same
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Another patch based on Kevin's code
patch_quitApp.txt (text/plain), 8.15 KB, created by
Sky Yan
on 2008-02-21 03:16:03 EST
(
hide
)
Description:
Another patch based on Kevin's code
Filename:
MIME Type:
Creator:
Sky Yan
Created:
2008-02-21 03:16:03 EST
Size:
8.15 KB
patch
obsolete
>Index: Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java,v >retrieving revision 1.14 >diff -u -r1.14 Display.java >--- Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java 3 Dec 2007 17:17:53 -0000 1.14 >+++ Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java 21 Feb 2008 08:06:47 -0000 >@@ -97,7 +97,7 @@ > Event [] eventQueue; > EventTable eventTable, filterTable; > boolean disposing; >- >+ > /* Sync/Async Widget Communication */ > Synchronizer synchronizer; > Thread thread; >@@ -114,6 +114,7 @@ > > NSPoint cascade = new NSPoint(); > >+// int jniRef; > Callback windowDelegateCallback2, windowDelegateCallback3, windowDelegateCallback4, windowDelegateCallback5; > Callback windowDelegateCallback6; > Callback dialogCallback3; >@@ -227,11 +228,14 @@ > Runnable timerList []; > NSTimer nsTimers []; > SWTWindowDelegate timerDelegate = (SWTWindowDelegate)new SWTWindowDelegate().alloc().init(); >+ SWTApplicationDelegate applicationDelegate; > > /* Display Data */ > Object data; > String [] keys; > Object [] values; >+ private Callback applicationDelegateCallback3; >+// private Callback applicationDelegateCallback2; > > /* > * TEMPORARY CODE. Install the runnable that >@@ -629,6 +633,8 @@ > > pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init(); > application = NSApplication.sharedApplication(); >+// jniRef = OS.NewGlobalRef(this); >+// if (jniRef == 0) error (SWT.ERROR_NO_HANDLES); > } > > static void deregister (Display display) { >@@ -659,6 +665,8 @@ > if (pool != null) pool.release(); > pool = null; > application = null; >+// if (jniRef != 0) OS.DeleteGlobalRef(jniRef); >+// jniRef = 0; > } > > /** >@@ -1517,6 +1525,14 @@ > protected void init () { > super.init (); > initClasses (); >+ initApplicationDelegate(); >+ application.finishLaunching(); >+} >+ >+void initApplicationDelegate() { >+ applicationDelegate = (SWTApplicationDelegate)new SWTApplicationDelegate().alloc().init(); >+// applicationDelegate.setTag(jniRef); >+ application.setDelegate(applicationDelegate); > } > > void initClasses () { >@@ -1524,6 +1540,13 @@ > int dialogProc3 = dialogCallback3.getAddress(); > if (dialogProc3 == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); > >+ applicationDelegateCallback3 = new Callback(this, "applicationDelegateProc", 3); >+ int appProc3 = applicationDelegateCallback3.getAddress(); >+ if (appProc3 == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); >+// applicationDelegateCallback2 = new Callback(this, "applicationDelegateProc", 2); >+// int appProc2 = applicationDelegateCallback2.getAddress(); >+// if (appProc2 == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); >+ > windowDelegateCallback3 = new Callback(this, "windowDelegateProc", 3); > int proc3 = windowDelegateCallback3.getAddress(); > if (proc3 == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); >@@ -1542,8 +1565,24 @@ > > int drawRectProc = OS.drawRect_CALLBACK(proc3); > >- String className = "SWTWindowDelegate"; >+ String className = "SWTApplicationDelegate"; > int cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); >+// OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); >+// OS.class_addMethod(cls, OS.sel_tag, proc2, "@:"); >+// OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i"); >+ OS.class_addMethod(cls, OS.sel_applicationWillFinishLaunching_1, appProc3, "@:@"); >+ OS.class_addMethod(cls, OS.sel_terminate_1, appProc3, "@:@"); >+// OS.class_addMethod(cls, OS.sel_terminate, appProc2, "@:"); >+ OS.class_addMethod(cls, OS.sel_orderFrontStandardAboutPanel_1, appProc3, "@:@"); >+ OS.class_addMethod(cls, OS.sel_hideOtherApplications_1, appProc3, "@:@"); >+ OS.class_addMethod(cls, OS.sel_hide_1, appProc3, "@:@"); >+ OS.class_addMethod(cls, OS.sel_unhideAllApplications_1, appProc3, "@:@"); >+ OS.class_addMethod(cls, OS.sel_applicationShouldTerminate_1, appProc3, "@:@"); >+ OS.class_addMethod(cls, OS.sel_applicationWillTerminate_1, appProc3, "@:@"); >+ OS.objc_registerClassPair(cls); >+ >+ className = "SWTWindowDelegate"; >+ cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); > OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i"); > OS.class_addMethod(cls, OS.sel_windowDidResize_1, proc3, "@:@"); > OS.class_addMethod(cls, OS.sel_windowShouldClose_1, proc3, "@:@"); >@@ -2940,6 +2979,62 @@ > object.performSelectorOnMainThread_withObject_waitUntilDone_(OS.sel_release, null, false); > } > >+//int applicationDelegateProc(int delegate, int sel) { >+// if (sel == OS.sel_finishLaunching) { >+// System.out.println("finish!"); >+// } >+// if (sel == OS.sel_terminate) { >+// System.out.println("terminate!"); >+// } >+// return 0; >+//} >+ >+int applicationDelegateProc(int id, int sel, int arg0) { >+ if (sel == OS.sel_applicationWillFinishLaunching_1) { >+ id dict = NSDictionary.dictionaryWithObject(applicationDelegate, NSString.stringWith("NSOwner")); >+ NSBundle.loadNibFile(NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Resources/English.lproj/DefaultApp.nib"), dict, null); >+ >+ //replace %@ with application name >+ NSMenu mainmenu = application.mainMenu(); >+ NSMenuItem appitem = mainmenu.itemAtIndex(0); >+ if (appitem != null) { >+ NSMenu sm = appitem.submenu(); >+ NSArray ia = sm.itemArray(); >+ for(int i = 0; i < ia.count(); i++) { >+ NSMenuItem ni = new NSMenuItem(ia.objectAtIndex(i)); >+ NSString title = ni.title().stringByReplacingOccurrencesOfString_withString_(NSString.stringWith("%@"), NSString.stringWith(APP_NAME)); >+ ni.setTitle(title); >+ } >+ } >+ } else if (sel == OS.sel_terminate_1) { >+ application.terminate(application); >+ } else if (sel == OS.sel_orderFrontStandardAboutPanel_1) { >+ Event event = new Event (); >+ sendEvent (SWT.ABORT, event); >+ } else if (sel == OS.sel_hideOtherApplications_1) { >+ application.hideOtherApplications(application); >+ } else if (sel == OS.sel_hide_1) { >+ application.hide(application); >+ } else if (sel == OS.sel_unhideAllApplications_1) { >+ application.unhideAllApplications(application); >+ } else if (sel == OS.sel_applicationShouldTerminate_1) { >+ if (!disposing) { >+ Event event = new Event (); >+ sendEvent (SWT.Close, event); >+ if (event.doit) { >+ return OS.NSTerminateNow; >+ } >+ } >+ return OS.NSTerminateCancel; >+ } else if (sel == OS.sel_applicationWillTerminate_1) { >+ dispose(); >+ } /*else { >+ System.out.println("window delegate proc sel = " + sel); >+ }*/ >+ return 0; >+} >+ >+ > int dialogProc(int id, int sel, int arg0) { > int jniRef = OS.objc_msgSend(id, OS.sel_tag); > if (jniRef == 0 || jniRef == -1) return 0; >Index: Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSBundle.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSBundle.java,v >retrieving revision 1.3 >diff -u -r1.3 NSBundle.java >--- Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSBundle.java 19 Nov 2007 15:45:20 -0000 1.3 >+++ Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSBundle.java 21 Feb 2008 08:00:05 -0000 >@@ -213,4 +213,8 @@ > return OS.objc_msgSend(this.id, OS.sel_unload) != 0; > } > >+public static boolean loadNibFile(id fileName, id dict, id zone) { >+ return OS.objc_msgSend(OS.class_NSBundle, OS.sel_loadNibFile_1externalNameTable_1withZone_1, fileName.id, dict.id, 0) != 0; >+} >+ > } >Index: Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTApplicationDelegate.java >=================================================================== >RCS file: Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTApplicationDelegate.java >diff -N Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTApplicationDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTApplicationDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,19 @@ >+package org.eclipse.swt.internal.cocoa; >+ >+public class SWTApplicationDelegate extends NSObject { >+ public SWTApplicationDelegate() { >+ super(0); >+ } >+ >+ public SWTApplicationDelegate(int id) { >+ super(id); >+ } >+ >+ public int tag() { >+ return OS.objc_msgSend(id, OS.sel_tag); >+ } >+ public void setTag(int tag) { >+ OS.objc_msgSend(id, OS.sel_setTag_1, tag); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 211359
:
88108
|
90117
|
90304
| 90305