/* * Class: jogamp_newt_driver_x11_DisplayDriver * Method: CompleteDisplay * Signature: (J)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_CompleteDisplay0 (JNIEnv *env, jobject obj, jlong display) { Display * dpy = (Display *)(intptr_t)display; jlong javaObjectAtom; jlong windowDeleteAtom; if(dpy==NULL) { NewtCommon_FatalError(env, "invalid display connection.."); } javaObjectAtom = (jlong) XInternAtom(dpy, "NEWT_JAVA_OBJECT", False); if(None==javaObjectAtom) { NewtCommon_throwNewRuntimeException(env, "could not create Atom NEWT_JAVA_OBJECT, bail out!"); return; } windowDeleteAtom = (jlong) XInternAtom(dpy, "WM_DELETE_WINDOW", False); if(None==windowDeleteAtom) { NewtCommon_throwNewRuntimeException(env, "could not create Atom WM_DELETE_WINDOW, bail out!"); return; } // XSetCloseDownMode(dpy, RetainTemporary); // Just a try .. DBG_PRINT("X11: X11Display_completeDisplay dpy %p\n", dpy); (*env)->CallVoidMethod(env, obj, displayCompletedID, javaObjectAtom, windowDeleteAtom); }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: getMonitorViewport0 * Signature: (J)[I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorViewport0 (JNIEnv *env, jclass clazz, jlong monitorInfo) { XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; if( NULL == xrrCrtcInfo ) { // n/a return NULL; } if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { // disabled return NULL; } jsize propCount = 4; jint prop[ propCount ]; int propIndex = 0; prop[propIndex++] = xrrCrtcInfo->x; prop[propIndex++] = xrrCrtcInfo->y; prop[propIndex++] = xrrCrtcInfo->width; prop[propIndex++] = xrrCrtcInfo->height; jintArray properties = (*env)->NewIntArray(env, propCount); if (properties == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); } (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); return properties; }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: getMonitorCurrentMode0 * Signature: (JJ)[I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorCurrentMode0 (JNIEnv *env, jclass clazz, jlong screenResources, jlong monitorInfo) { XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; if( NULL == resources || NULL == xrrCrtcInfo ) { // n/a return NULL; } if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { // disabled return NULL; } RRMode modeId = xrrCrtcInfo->mode; XRRModeInfo *mode = findMode(resources, modeId); if( NULL == mode ) { // oops .. return NULL; } unsigned int dots = mode->hTotal * mode->vTotal; int refresh = (int) ( getVRefresh(mode) * 100.0f ); // Hz * 100 int flags = 0; if (mode->modeFlags & RR_Interlace) { flags |= FLAG_INTERLACE; } if (mode->modeFlags & RR_DoubleScan) { flags |= FLAG_DOUBLESCAN; } jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; prop[propIndex++] = mode->width; prop[propIndex++] = mode->height; prop[propIndex++] = 32; // TODO: XRandR > 1.4 may support bpp prop[propIndex++] = refresh; prop[propIndex++] = flags; prop[propIndex++] = mode->id; prop[propIndex++] = NewtScreen_XRotation2Degree(env, xrrCrtcInfo->rotation); jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: getMonitorDevice0 * Signature: (JJJJ)[I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice0 (JNIEnv *env, jclass clazz, jlong display, jlong screenResources, jlong monitorInfo, jint crt_idx) { Display * dpy = (Display *) (intptr_t) display; XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; if( NULL == resources || NULL == xrrCrtcInfo || crt_idx >= resources->ncrtc ) { // n/a return NULL; } if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { // disabled return NULL; } RROutput output = xrrCrtcInfo->outputs[0]; XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output); int numModes = xrrOutputInfo->nmode; jsize propCount = MIN_MONITOR_DEVICE_PROPERTIES - 1 + numModes; jint prop[ propCount ]; int propIndex = 0; prop[propIndex++] = propCount; prop[propIndex++] = crt_idx; prop[propIndex++] = xrrOutputInfo->mm_width; prop[propIndex++] = xrrOutputInfo->mm_height; prop[propIndex++] = xrrCrtcInfo->x; prop[propIndex++] = xrrCrtcInfo->y; prop[propIndex++] = xrrCrtcInfo->width; prop[propIndex++] = xrrCrtcInfo->height; prop[propIndex++] = xrrCrtcInfo->mode; // current mode id prop[propIndex++] = NewtScreen_XRotation2Degree(env, xrrCrtcInfo->rotation); int i; for(i=0; i<numModes; i++) { // avail modes .. prop[propIndex++] = xrrOutputInfo->modes[i]; } XRRFreeOutputInfo (xrrOutputInfo); jintArray properties = (*env)->NewIntArray(env, propCount); if (properties == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); } (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); return properties; }
Rotation NewtScreen_Degree2XRotation(JNIEnv *env, int degree) { Rotation xrot; if(degree == 0) { xrot = RR_Rotate_0; } else if(degree == 90) { xrot = RR_Rotate_90; } else if(degree == 180) { xrot = RR_Rotate_180; } else if(degree == 270) { xrot = RR_Rotate_270; } else { NewtCommon_throwNewRuntimeException(env, "invalid degree: %d", degree); } return xrot; }
int NewtScreen_XRotation2Degree(JNIEnv *env, Rotation xrotation) { int degree; if(xrotation == RR_Rotate_0) { degree = 0; } else if(xrotation == RR_Rotate_90) { degree = 90; } else if(xrotation == RR_Rotate_180) { degree = 180; } else if(xrotation == RR_Rotate_270) { degree = 270; } else { NewtCommon_throwNewRuntimeException(env, "invalid native rotation: %d", xrotation); } return degree; }
/* * Class: jogamp_newt_driver_x11_ScreenDriver * Method: GetRandRVersion0 * Signature: (J)[I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getRandRVersion0 (JNIEnv *env, jclass clazz, jlong display) { Display * dpy = (Display *)(intptr_t)display; jint version[2]; if( 0 == XRRQueryVersion(dpy, &version[0], &version[1] ) ) { version[0] = 0; version[1] = 0; } jintArray jversion = (*env)->NewIntArray(env, 2); if (jversion == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size 2"); } // move from the temp structure to the java structure (*env)->SetIntArrayRegion(env, jversion, 0, 2, version); return jversion; }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: getMonitorDeviceIds0 * Signature: (J)[I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDeviceIds0 (JNIEnv *env, jclass clazz, jlong screenResources) { XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; int ncrtc = ( NULL != resources ) ? resources->ncrtc : 0; jintArray properties = NULL; if( 0 < ncrtc ) { int crtcs[ncrtc]; int i; for(i=0; i<ncrtc; i++) { crtcs[i] = (int)(intptr_t)resources->crtcs[i]; } properties = (*env)->NewIntArray(env, ncrtc); if (properties == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", ncrtc); } (*env)->SetIntArrayRegion(env, properties, 0, ncrtc, crtcs); } return properties; }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: getMonitorMode0 * Signature: (JI)[I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorMode0 (JNIEnv *env, jclass clazz, jlong screenResources, jint mode_idx) { XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; if( NULL == resources || mode_idx >= resources->nmode ) { return NULL; } XRRModeInfo *mode = &resources->modes[mode_idx]; unsigned int dots = mode->hTotal * mode->vTotal; int refresh = (int) ( getVRefresh(mode) * 100.0f ); // Hz * 100 int flags = 0; if (mode->modeFlags & RR_Interlace) { flags |= FLAG_INTERLACE; } if (mode->modeFlags & RR_DoubleScan) { flags |= FLAG_DOUBLESCAN; } jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; prop[propIndex++] = mode->width; prop[propIndex++] = mode->height; prop[propIndex++] = 32; // TODO: XRandR > 1.4 may support bpp prop[propIndex++] = refresh; prop[propIndex++] = flags; prop[propIndex++] = mode->id; prop[propIndex++] = -1; // rotation placeholder jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: getAvailableRotations0 * Signature: (J)I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableRotations0 (JNIEnv *env, jclass clazz, jlong monitorInfo) { XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; if( NULL == xrrCrtcInfo ) { return NULL; } Rotation rotations_supported = xrrCrtcInfo->rotations; int num_rotations = 0; int rotations[4]; if(0 != (rotations_supported & RR_Rotate_0)) { rotations[num_rotations++] = 0; } if(0 != (rotations_supported & RR_Rotate_90)) { rotations[num_rotations++] = 90; } if(0 != (rotations_supported & RR_Rotate_180)) { rotations[num_rotations++] = 180; } if(0 != (rotations_supported & RR_Rotate_270)) { rotations[num_rotations++] = 270; } jintArray properties = NULL; if(num_rotations>0) { properties = (*env)->NewIntArray(env, num_rotations); if (properties == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); } // move from the temp structure to the java structure (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); } return properties; }
void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, jlong windowDeleteAtom) { Atom wm_delete_atom = (Atom)windowDeleteAtom; int num_events = 100; int autoRepeatModifiers = 0; if ( NULL == dpy ) { return; } // Periodically take a break while( num_events > 0 ) { jobject jwindow = NULL; XEvent evt; KeySym keySym = 0; jint modifiers = 0; char keyChar = 0; char text[255]; // XEventsQueued(dpy, X): // QueuedAlready == XQLength(): No I/O Flush or system call doesn't work on some cards (eg ATI) ?) // QueuedAfterFlush == XPending(): I/O Flush only if no already queued events are available // QueuedAfterReading : QueuedAlready + if queue==0, attempt to read more .. // if ( 0 >= XPending(dpy) ) if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { // DBG_PRINT( "X11: DispatchMessages 0x%X - Leave 1\n", dpy); return; } XNextEvent(dpy, &evt); num_events--; if(dpy!=evt.xany.display) { NewtCommon_throwNewRuntimeException(env, "wrong display, bail out!"); return ; } if( 0==evt.xany.window ) { DBG_PRINT( "X11: DispatchMessages dpy %p, Event %d - Window NULL, ignoring\n", (void*)dpy, (int)evt.type); continue; } // DBG_PRINT( "X11: DispatchMessages dpy %p, win %p, Event %d\n", (void*)dpy, (void*)evt.xany.window, (int)evt.type); jwindow = getJavaWindowProperty(env, dpy, evt.xany.window, javaObjectAtom, #ifdef VERBOSE_ON True #else False #endif ); if(NULL==jwindow) { fprintf(stderr, "Warning: NEWT X11 DisplayDispatch %p, Couldn't handle event %d for X11 window %p\n", (void*)dpy, evt.type, (void*)evt.xany.window); continue; } switch(evt.type) { case KeyRelease: if (XEventsQueued(dpy, QueuedAfterReading)) { XEvent nevt; XPeekEvent(dpy, &nevt); if (nevt.type == KeyPress && nevt.xkey.time == evt.xkey.time && nevt.xkey.keycode == evt.xkey.keycode) { autoRepeatModifiers |= EVENT_AUTOREPEAT_MASK; } else { autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK; } } // fall through intended case KeyPress: if(XLookupString(&evt.xkey,text,255,&keySym,0)==1) { KeySym lower_return = 0, upper_return = 0; keyChar=text[0]; XConvertCase(keySym, &lower_return, &upper_return); // always return upper case, set modifier masks (SHIFT, ..) keySym = X11KeySym2NewtVKey(upper_return); } else { keyChar=0; keySym = X11KeySym2NewtVKey(keySym); } modifiers |= X11InputState2NewtModifiers(evt.xkey.state) | autoRepeatModifiers; break; case ButtonPress: case ButtonRelease: case MotionNotify: modifiers |= X11InputState2NewtModifiers(evt.xbutton.state); break; default: break; } switch(evt.type) { case ButtonPress: (*env)->CallVoidMethod(env, jwindow, requestFocusID, JNI_FALSE); #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, modifiers, (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED, modifiers, (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); #endif break; case ButtonRelease: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, modifiers, (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED, modifiers, (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); #endif break; case MotionNotify: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, modifiers, (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED, modifiers, (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); #endif break; case EnterNotify: DBG_PRINT( "X11: event . EnterNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y); #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED, modifiers, (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED, modifiers, (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); #endif break; case LeaveNotify: DBG_PRINT( "X11: event . LeaveNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y); #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED, modifiers, (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED, modifiers, (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); #endif break; case KeyPress: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_PRESSED, modifiers, keySym, (jchar) -1); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_PRESSED, modifiers, keySym, (jchar) -1); #endif break; case KeyRelease: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, modifiers, keySym, (jchar) -1); (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, modifiers, keySym, (jchar) keyChar); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, modifiers, keySym, (jchar) -1); (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, modifiers, keySym, (jchar) keyChar); #endif break; case DestroyNotify: DBG_PRINT( "X11: event . DestroyNotify call %p, parent %p, child-event: %d\n", (void*)evt.xdestroywindow.window, (void*)evt.xdestroywindow.event, evt.xdestroywindow.window != evt.xdestroywindow.event); if ( evt.xdestroywindow.window == evt.xdestroywindow.event ) { // ignore child destroy notification } break; case CreateNotify: DBG_PRINT( "X11: event . CreateNotify call %p, parent %p, child-event: 1\n", (void*)evt.xcreatewindow.window, (void*) evt.xcreatewindow.parent); break; case ConfigureNotify: DBG_PRINT( "X11: event . ConfigureNotify call %p (parent %p, above %p) %d/%d %dx%d %d, child-event: %d\n", (void*)evt.xconfigure.window, (void*)evt.xconfigure.event, (void*)evt.xconfigure.above, evt.xconfigure.x, evt.xconfigure.y, evt.xconfigure.width, evt.xconfigure.height, evt.xconfigure.override_redirect, evt.xconfigure.window != evt.xconfigure.event); if ( evt.xconfigure.window == evt.xconfigure.event ) { // ignore child window change notification { // update insets int left, right, top, bottom; NewtWindows_updateInsets(env, jwindow, dpy, evt.xany.window, &left, &right, &top, &bottom); } (*env)->CallVoidMethod(env, jwindow, sizeChangedID, JNI_FALSE, (jint) evt.xconfigure.width, (jint) evt.xconfigure.height, JNI_FALSE); (*env)->CallVoidMethod(env, jwindow, positionChangedID, JNI_FALSE, (jint) evt.xconfigure.x, (jint) evt.xconfigure.y); } break; case ClientMessage: if (evt.xclient.send_event==True && evt.xclient.data.l[0]==wm_delete_atom) { // windowDeleteAtom jboolean closed; DBG_PRINT( "X11: event . ClientMessage call %p type 0x%X ..\n", (void*)evt.xclient.window, (unsigned int)evt.xclient.message_type); closed = (*env)->CallBooleanMethod(env, jwindow, windowDestroyNotifyID, JNI_FALSE); DBG_PRINT( "X11: event . ClientMessage call %p type 0x%X, closed: %d\n", (void*)evt.xclient.window, (unsigned int)evt.xclient.message_type, (int)closed); // Called by Window.java: CloseWindow(); num_events = 0; // end loop in case of destroyed display } break; case FocusIn: DBG_PRINT( "X11: event . FocusIn call %p\n", (void*)evt.xvisibility.window); (*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_FALSE, JNI_TRUE); break; case FocusOut: DBG_PRINT( "X11: event . FocusOut call %p\n", (void*)evt.xvisibility.window); (*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_FALSE, JNI_FALSE); break; case Expose: DBG_PRINT( "X11: event . Expose call %p %d/%d %dx%d count %d\n", (void*)evt.xexpose.window, evt.xexpose.x, evt.xexpose.y, evt.xexpose.width, evt.xexpose.height, evt.xexpose.count); if (evt.xexpose.count == 0 && evt.xexpose.width > 0 && evt.xexpose.height > 0) { (*env)->CallVoidMethod(env, jwindow, windowRepaintID, JNI_FALSE, evt.xexpose.x, evt.xexpose.y, evt.xexpose.width, evt.xexpose.height); } break; case MapNotify: DBG_PRINT( "X11: event . MapNotify call Event %p, Window %p, override_redirect %d, child-event: %d\n", (void*)evt.xmap.event, (void*)evt.xmap.window, (int)evt.xmap.override_redirect, evt.xmap.event!=evt.xmap.window); if( evt.xmap.event == evt.xmap.window ) { // ignore child window notification { // update insets int left, right, top, bottom; NewtWindows_updateInsets(env, jwindow, dpy, evt.xany.window, &left, &right, &top, &bottom); } (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE, JNI_TRUE); } break; case UnmapNotify: DBG_PRINT( "X11: event . UnmapNotify call Event %p, Window %p, from_configure %d, child-event: %d\n", (void*)evt.xunmap.event, (void*)evt.xunmap.window, (int)evt.xunmap.from_configure, evt.xunmap.event!=evt.xunmap.window); if( evt.xunmap.event == evt.xunmap.window ) { // ignore child window notification (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE, JNI_FALSE); } break; case ReparentNotify: { jlong parentResult; // 0 if root, otherwise proper value Window winRoot, winTopParent; #ifdef VERBOSE_ON Window oldParentRoot, oldParentTopParent; Window parentRoot, parentTopParent; if( 0 == NewtWindows_getRootAndParent(dpy, evt.xreparent.event, &oldParentRoot, &oldParentTopParent) ) { oldParentRoot=0; oldParentTopParent = 0; } if( 0 == NewtWindows_getRootAndParent(dpy, evt.xreparent.parent, &parentRoot, &parentTopParent) ) { parentRoot=0; parentTopParent = 0; } #endif if( 0 == NewtWindows_getRootAndParent(dpy, evt.xreparent.window, &winRoot, &winTopParent) ) { winRoot=0; winTopParent = 0; } if(evt.xreparent.parent == winRoot) { parentResult = 0; // our java indicator for root window } else { parentResult = (jlong) (intptr_t) evt.xreparent.parent; } #ifdef VERBOSE_ON DBG_PRINT( "X11: event . ReparentNotify: call %d/%d OldParent %p (root %p, top %p), NewParent %p (root %p, top %p), Window %p (root %p, top %p)\n", evt.xreparent.x, evt.xreparent.y, (void*)evt.xreparent.event, (void*)oldParentRoot, (void*)oldParentTopParent, (void*)evt.xreparent.parent, (void*)parentRoot, (void*)parentTopParent, (void*)evt.xreparent.window, (void*)winRoot, (void*)winTopParent); #endif (*env)->CallVoidMethod(env, jwindow, reparentNotifyID, (jlong)evt.xreparent.parent); } break; // unhandled events .. yet .. default: DBG_PRINT("X11: event . unhandled %d 0x%X call %p\n", (int)evt.type, (unsigned int)evt.type, (void*)evt.xunmap.window); } } }
/* * Class: jogamp_newt_driver_x11_RandR13 * Method: getMonitorDevice0 * Signature: (JJJJ)[I */ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice0 (JNIEnv *env, jclass clazz, jlong display, jlong screenResources, jlong monitorInfo, jint crt_id) { Display * dpy = (Display *) (intptr_t) display; XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; RRCrtc crtc = findRRCrtc( resources, (RRCrtc)(intptr_t)crt_id ); if( 0 == crtc ) { // n/a return NULL; } XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; if( NULL == xrrCrtcInfo ) { // n/a return NULL; } if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { // disabled return NULL; } Window root = RootWindow(dpy, 0); // FIXME screen_idx); RROutput pxid = XRRGetOutputPrimary (dpy, root); int isPrimary = 0; RROutput output = xrrCrtcInfo->outputs[0]; if ( None != pxid && pxid == output ) { isPrimary = 1; } XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output); int numModes = xrrOutputInfo->nmode; jsize propCount = MIN_MONITOR_DEVICE_PROPERTIES - 1 + numModes; jint prop[ propCount ]; int propIndex = 0; prop[propIndex++] = propCount; prop[propIndex++] = crt_id; prop[propIndex++] = 0; // isClone, does not work: 0 < xrrOutputInfo->nclone ? 1 : 0; prop[propIndex++] = isPrimary; prop[propIndex++] = xrrOutputInfo->mm_width; prop[propIndex++] = xrrOutputInfo->mm_height; prop[propIndex++] = xrrCrtcInfo->x; // rotated viewport pixel units prop[propIndex++] = xrrCrtcInfo->y; // rotated viewport pixel units prop[propIndex++] = xrrCrtcInfo->width; // rotated viewport pixel units prop[propIndex++] = xrrCrtcInfo->height; // rotated viewport pixel units prop[propIndex++] = xrrCrtcInfo->x; // rotated viewport window units (same) prop[propIndex++] = xrrCrtcInfo->y; // rotated viewport window units (same) prop[propIndex++] = xrrCrtcInfo->width; // rotated viewport window units (same) prop[propIndex++] = xrrCrtcInfo->height; // rotated viewport window units (same) prop[propIndex++] = xrrCrtcInfo->mode; // current mode id prop[propIndex++] = NewtScreen_XRotation2Degree(env, xrrCrtcInfo->rotation); int i; for(i=0; i<numModes; i++) { // avail modes .. prop[propIndex++] = xrrOutputInfo->modes[i]; } XRRFreeOutputInfo (xrrOutputInfo); jintArray properties = (*env)->NewIntArray(env, propCount); if (properties == NULL) { NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); } (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); return properties; }