summaryrefslogtreecommitdiffstats
path: root/src/newt/native/X11Window.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-07-07 15:02:13 +0200
committerSven Gothel <[email protected]>2010-07-07 15:02:13 +0200
commita4b16ad544f3f7872f15e52d7ada7dc1e506d333 (patch)
treec5e1ed12c15e07e99f644661c2ad1065d1ddff92 /src/newt/native/X11Window.c
parent4bf5b13090d9654921e475415b23fc8428320a0e (diff)
GLAutoDrawable: setAnimator/getAnimator/invoke/display changes; NEWT: Adding native repaint; Fix reparent/fullscreen
New: NEWT Native Repaint ========================= Support for native repaint, which shall call display() in case no animator is running. GLAutoDrawable invoke(GLRunnable) impl. handles case if invoked on animator thread, or no animator thread is running (issueing a display() call). The impl resides in GLDrawableHelper. The Animator un-/registers itself at the GLAutoDrawable via setAnimator. New: NEWT AWT/NEWT Parenting Focus Handling ============================================ Introducing Window.FocusRunnable, to be registered at the NEWT Window, which will be executed before the native focus claim. Window.FocusRunnable's run method returns a boolean, which determines whether the native implementation shall proceed claiming the native focus. This API focus hook is necessary to allow an optional underlying windowing toolkit, ie AWT (see usage NewtCanvasAWT), to make the focus traversal transparent. Fix: GLEventListener / GLDrawableHelper ======================================== GLEventListener's init() and glViewport()/reshape() method must be called before the 1st display() and after a dispose() call. It could miss the 1st display() call if added after the setVisible(true) call - due to the native repainting. The impl resides in GLDrawableHelper. Fix: Misc NEWT ============== Window reparent issues a resize() and display() call, if it is visible. native Window uses direct send.*Event for input events (again), instead of enqueueing it for performance. Window impl all status change native event Java callbacks, instead of having duplicated code in all implementations. Fullscreen, reposition at zero. Reparent/Fullscreen repaint if visible. Native reparent/fullscreen, fix glitches on Windows (visibility while reparenting)
Diffstat (limited to 'src/newt/native/X11Window.c')
-rwxr-xr-xsrc/newt/native/X11Window.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index dbf833633..60caab662 100755
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -161,6 +161,7 @@ static jmethodID windowRepaintID = NULL;
static jmethodID windowCreatedID = NULL;
static jmethodID sendMouseEventID = NULL;
static jmethodID sendKeyEventID = NULL;
+static jmethodID focusActionID = NULL;
static jmethodID displayCompletedID = NULL;
@@ -372,18 +373,42 @@ static jobject getJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, j
return jwindow;
}
-static void NewtWindows_requestFocus0 (Display *dpy, Window w, XWindowAttributes *xwa) {
- // Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable
- if(xwa->map_state == IsViewable) {
- XSetInputFocus(dpy, w, RevertToParent, CurrentTime);
+/**
+static Window NewtWindows_getParent (Display *dpy, Window w) {
+ Window root_return=0;
+ Window parent_return=0;
+ Window *children_return=NULL;
+ unsigned int nchildren_return=0;
+
+ Status res = XQueryTree(dpy, w, &root_return, &parent_return, &children_return, &nchildren_return);
+ if(NULL!=children_return) {
+ XFree(children_return);
+ }
+ if(0!=res) {
+ return parent_return;
+ }
+ return 0;
+} */
+
+static void NewtWindows_requestFocus0 (JNIEnv *env, jobject window, Display *dpy, Window w, XWindowAttributes *xwa) {
+ Window focus_return;
+ int revert_to_return;
+ XGetInputFocus(dpy, &focus_return, &revert_to_return);
+ if(focus_return!=w) {
+ // Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable
+ if( JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) {
+ if(xwa->map_state == IsViewable) {
+ XSetInputFocus(dpy, w, RevertToParent, CurrentTime);
+ }
+ }
}
}
-static void NewtWindows_requestFocus1 (Display *dpy, Window w) {
+static void NewtWindows_requestFocus1 (JNIEnv *env, jobject window, Display *dpy, Window w) {
XWindowAttributes xwa;
XGetWindowAttributes(dpy, w, &xwa);
- NewtWindows_requestFocus0 (dpy, w, &xwa);
+ NewtWindows_requestFocus0 (env, window, dpy, w, &xwa);
XSync(dpy, False);
}
@@ -505,7 +530,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
switch(evt.type) {
case ButtonPress:
- NewtWindows_requestFocus1 ( dpy, evt.xany.window );
+ NewtWindows_requestFocus1 ( env, jwindow, dpy, evt.xany.window );
(*env)->CallVoidMethod(env, jwindow, sendMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
(jint) evt.xbutton.state,
@@ -674,6 +699,7 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V");
sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
+ focusActionID = (*env)->GetMethodID(env, clazz, "focusAction", "()Z");
if (sizeChangedID == NULL ||
positionChangedID == NULL ||
@@ -684,7 +710,8 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
windowRepaintID == NULL ||
windowCreatedID == NULL ||
sendMouseEventID == NULL ||
- sendKeyEventID == NULL) {
+ sendKeyEventID == NULL ||
+ focusActionID == NULL) {
return JNI_FALSE;
}
return JNI_TRUE;
@@ -941,7 +968,9 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosition0
}
static void NewtWindows_reparentWindow
- (Display * dpy, Screen * scrn, Window w, XWindowAttributes *xwa, jlong jparent, jint x, jint y, jboolean undecorated, jboolean isVisible)
+ (JNIEnv *env, jobject obj,
+ Display * dpy, Screen * scrn, Window w, XWindowAttributes *xwa, jlong jparent,
+ jint x, jint y, jboolean undecorated, jboolean isVisible)
{
Window parent = (0!=jparent)?(Window)jparent:XRootWindowOfScreen(scrn);
@@ -990,7 +1019,7 @@ static void NewtWindows_reparentWindow
XSync(dpy, False); */
if(JNI_TRUE == isVisible) {
- NewtWindows_requestFocus0 ( dpy, w, xwa );
+ NewtWindows_requestFocus0 ( env, obj, dpy, w, xwa );
XSync(dpy, False);
}
@@ -1023,7 +1052,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0
XSync(dpy, False);
XGetWindowAttributes(dpy, w, &xwa);
- NewtWindows_reparentWindow(dpy, scrn, w, &xwa, jparent, x, y, undecorated, isVisible);
+ NewtWindows_reparentWindow(env, obj, dpy, scrn, w, &xwa, jparent, x, y, undecorated, isVisible);
XSync(dpy, False);
memset(&xwc, 0, sizeof(XWindowChanges));
@@ -1058,7 +1087,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_reparentWindow0
XSync(dpy, False);
XGetWindowAttributes(dpy, w, &xwa);
- NewtWindows_reparentWindow(dpy, scrn, w, &xwa, jparent, x, y, undecorated, isVisible);
+ NewtWindows_reparentWindow(env, obj, dpy, scrn, w, &xwa, jparent, x, y, undecorated, isVisible);
XSync(dpy, False);
DBG_PRINT( "X11: reparentWindow0 X\n");
@@ -1072,7 +1101,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_reparentWindow0
JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_requestFocus0
(JNIEnv *env, jobject obj, jlong display, jlong window)
{
- NewtWindows_requestFocus1 ( (Display *) (intptr_t) display, (Window)window ) ;
+ NewtWindows_requestFocus1 ( env, obj, (Display *) (intptr_t) display, (Window)window ) ;
}
/*