*** empty log message ***

This commit is contained in:
Elias Naur 2003-09-26 18:36:54 +00:00
parent 17b6a501e4
commit 88b3bcabed
2 changed files with 37 additions and 19 deletions

View File

@ -1579,7 +1579,7 @@ static void extgl_InitializeWGL(JNIEnv *env, jobject ext_set)
/*-----------------------------------------------------*/ /*-----------------------------------------------------*/
#ifdef _AGL #ifdef _AGL
static int extgl_InitializeAGL() static int extgl_InitializeAGL(JNIEnv *env, jobject ext_set)
{ {
// add in AGL extensions here // add in AGL extensions here

View File

@ -95,13 +95,13 @@ static void setWindowTitle(JNIEnv *env, jstring title_obj) {
// dumpRootMenu(); // dumpRootMenu();
} }
static pascal OSStatus doWindowClose(EventHandlerCallRef next_handler, EventRef event, void *user_data) { static pascal OSStatus doQuit(EventHandlerCallRef next_handler, EventRef event, void *user_data) {
printf("Close requested\n"); printf("Close requested\n");
close_requested = true; close_requested = true;
return noErr; return noErr;
} }
static void registerEventHandlers(void) { static void registerEventHandlers(JNIEnv *env) {
/*EventTargetRef event_target = GetWindowEventTarget(win_ref); /*EventTargetRef event_target = GetWindowEventTarget(win_ref);
status = InstallStandardEventHandler(event_target); status = InstallStandardEventHandler(event_target);
if (noErr != status) { if (noErr != status) {
@ -109,12 +109,28 @@ static void registerEventHandlers(void) {
throwException(env, "Could not install default window event handler"); throwException(env, "Could not install default window event handler");
return; return;
}*/ }*/
EventTypeSpec eventType; EventTypeSpec event_types[1];
eventType.eventClass = kEventClassWindow; OSStatus err;
eventType.eventKind = kEventWindowClose; EventHandlerUPP handler_upp = NewEventHandlerUPP(doQuit);
EventHandlerUPP handlerUPP = NewEventHandlerUPP(doWindowClose); event_types[0].eventClass = kEventClassWindow;
InstallWindowEventHandler(win_ref, handlerUPP, 1, &eventType, NULL, NULL); event_types[0].eventKind = kEventWindowClose;
DisposeEventHandlerUPP(handlerUPP); err = InstallWindowEventHandler(win_ref, handler_upp, 1, event_types, NULL, NULL);
if (noErr != err) {
DisposeEventHandlerUPP(handler_upp);
throwException(env, "Could not register window event handler");
return;
}
event_types[0].eventClass = kEventClassApplication;
event_types[0].eventKind = kEventAppQuit;
/*event_types[1].eventClass = kEventClassAppleEvent;
event_types[1].eventKind = kEventAppleEvent;*/
err = InstallApplicationEventHandler(handler_upp, 1, event_types, NULL, NULL);
if (noErr != err) {
DisposeEventHandlerUPP(handler_upp);
throwException(env, "Could not register application event handler");
return;
}
DisposeEventHandlerUPP(handler_upp);
} }
@ -124,10 +140,11 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested(JNIEnv
return saved; return saved;
} }
OSErr aehandler(const AppleEvent * theAppleEvent, AppleEvent * reply, SInt32 handlerRefcon) { /*OSErr aehandler(const AppleEvent * theAppleEvent, AppleEvent * reply, SInt32 handlerRefcon) {
printf("handler called\n"); printf("handler called\n");
return noErr; return noErr;
} }
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate(JNIEnv *env, jclass clazz, jstring title, jint x, jint y, jint width, jint height, jboolean fullscreen, jint bpp, jint alpha, jint depth, jint stencil, jobject ext_set) { JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate(JNIEnv *env, jclass clazz, jstring title, jint x, jint y, jint width, jint height, jboolean fullscreen, jint bpp, jint alpha, jint depth, jint stencil, jobject ext_set) {
Rect rect; Rect rect;
@ -157,11 +174,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate(JNIEnv *env, jclass
}*/ }*/
/*ProcessSerialNumber PSN; /*ProcessSerialNumber PSN;
GetCurrentProcess(&PSN); GetCurrentProcess(&PSN);
SetFrontProcess(&PSN); SetFrontProcess(&PSN);*/
EventQueueRef queue = GetCurrentEventQueue(); EventLoopRef queue = GetCurrentEventLoop();
if (queue == NULL) EventLoopRef main = GetMainEventLoop();
printf("null event queue\n");*/ QuitEventLoop(queue);
QuitEventLoop(main);
/*if (queue == main)
printf("equals\n");*/
SetRect(&rect, x, y, x + width, y + height); SetRect(&rect, x, y, x + width, y + height);
close_requested = false; close_requested = false;
@ -170,7 +189,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate(JNIEnv *env, jclass
throwException(env, "Could not create window"); throwException(env, "Could not create window");
return; return;
} }
registerEventHandlers(); registerEventHandlers(env);
setWindowTitle(env, title); setWindowTitle(env, title);
const RGBColor background_color = { 0, 0, 0 }; const RGBColor background_color = { 0, 0, 0 };
SetWindowContentColor(win_ref, &background_color); SetWindowContentColor(win_ref, &background_color);
@ -183,14 +202,13 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate(JNIEnv *env, jclass
SelectWindow(win_ref); SelectWindow(win_ref);
InitCursor(); InitCursor();
//QuitApplicationEventLoop(); //QuitApplicationEventLoop();
DebugPrintAllWindowGroups();
//RunApplicationEventLoop(); //RunApplicationEventLoop();
} }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update
(JNIEnv *env, jclass clazz) (JNIEnv *env, jclass clazz)
{ {
EventRef event; /*EventRef event;
OSStatus err; OSStatus err;
int num_events = GetNumEventsInQueue(GetCurrentEventQueue()); int num_events = GetNumEventsInQueue(GetCurrentEventQueue());
for (int i = 0; i < num_events; i++) { for (int i = 0; i < num_events; i++) {
@ -203,7 +221,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update
err = ReceiveNextEvent(0, NULL, 0, true, &event); err = ReceiveNextEvent(0, NULL, 0, true, &event);
/* if (kind == kEventClassAppleEvent) /* if (kind == kEventClassAppleEvent)
AEProcessAppleEvent(event);*/ AEProcessAppleEvent(event);*/
ReleaseEvent(event); /* ReleaseEvent(event);
} }
//RunCurrentEventLoop(0); //RunCurrentEventLoop(0);
/* if (eventLoopTimedOutErr != RunCurrentEventLoop(0)) /* if (eventLoopTimedOutErr != RunCurrentEventLoop(0))