136 |
DBG(dbg) << "Release current "<<wid<<"\n"; |
DBG(dbg) << "Release current "<<wid<<"\n"; |
137 |
} |
} |
138 |
|
|
139 |
|
/** If an exception occurred, print a debug message for it and clear it. |
140 |
|
*/ |
141 |
|
void javaExc(JNIEnv *env, const char *where) { |
142 |
|
if(env->ExceptionOccurred()) { |
143 |
|
cerr << "Exception in "<<where<<"\n"; |
144 |
|
env->ExceptionDescribe(); |
145 |
|
env->ExceptionClear(); |
146 |
|
} |
147 |
|
} |
148 |
|
|
149 |
struct GZZJNIEventHandler : public Os::Eventhandler { |
struct GZZJNIEventHandler : public Os::Eventhandler { |
150 |
|
|
151 |
jobject globalRef; |
jobject globalRef; |
178 |
void repaint() { |
void repaint() { |
179 |
DBG(dbg_event) << "CALLING REPAINT!!!\n"; |
DBG(dbg_event) << "CALLING REPAINT!!!\n"; |
180 |
jnienv_eventloop->CallVoidMethod(globalRef, mid_repaint); |
jnienv_eventloop->CallVoidMethod(globalRef, mid_repaint); |
181 |
|
javaExc(jnienv_eventloop, "repaint"); |
|
if(jnienv_eventloop->ExceptionOccurred()) { |
|
|
cerr << "Java exception in event handler!\n"; |
|
|
throw JavaException(); |
|
|
} |
|
182 |
|
|
183 |
// jnienv_eventloop->DeleteLocalRef(cls); |
// jnienv_eventloop->DeleteLocalRef(cls); |
184 |
|
|
190 |
DBG(dbg_event) << "Keystroke has been sent\n"; |
DBG(dbg_event) << "Keystroke has been sent\n"; |
191 |
|
|
192 |
jnienv_eventloop->CallVoidMethod(globalRef, mid_keystroke, jstr); |
jnienv_eventloop->CallVoidMethod(globalRef, mid_keystroke, jstr); |
193 |
|
javaExc(jnienv_eventloop, "keystroke"); |
194 |
|
|
195 |
DBG(dbg_event) << "Call finished\n"; |
DBG(dbg_event) << "Call finished\n"; |
196 |
} |
} |
198 |
virtual void mouse(int x, int y, int button, int type) { |
virtual void mouse(int x, int y, int button, int type) { |
199 |
|
|
200 |
jnienv_eventloop->CallVoidMethod(globalRef, mid_mousepress, x, y, button, type); |
jnienv_eventloop->CallVoidMethod(globalRef, mid_mousepress, x, y, button, type); |
201 |
|
javaExc(jnienv_eventloop, "mouse"); |
202 |
} |
} |
203 |
virtual void timeout(int id) { |
virtual void timeout(int id) { |
204 |
jnienv_eventloop->CallVoidMethod(globalRef, mid_timeout, id); |
jnienv_eventloop->CallVoidMethod(globalRef, mid_timeout, id); |
205 |
|
javaExc(jnienv_eventloop, "timeout"); |
206 |
} |
} |
207 |
virtual void windowClosed() { |
virtual void windowClosed() { |
208 |
jnienv_eventloop->CallVoidMethod(globalRef, mid_windowClosed); |
jnienv_eventloop->CallVoidMethod(globalRef, mid_windowClosed); |
209 |
|
javaExc(jnienv_eventloop, "windowClosed"); |
210 |
} |
} |
211 |
}; |
}; |
212 |
|
|