diff options
author | Sven Gothel <[email protected]> | 2015-03-20 21:42:23 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-03-20 21:42:23 +0100 |
commit | 2c88b6dfd4eb7e2cd9a50fa48e08ecafc980931a (patch) | |
tree | 2d89ec775fdd59499a934d622462b8915b89cead /src/newt/native/X11RandR11.c | |
parent | d9fe5c4aee7547bb89571c19c89ad173b63a4598 (diff) |
Bug 1147 - Fix XRandR13 Usage: Rotate / Change-Mode, use unique CRTC/Mode ids, ..
RandR 1.3 XRRSetCrtcConfig related:
- X11RandR13 now sets the new screen size via XRRSetScreenSize(..)
- X11RandR13 now propagates RRScreenChangeNotify events
via XRRUpdateConfiguration(event).
Hence reporting virtual desktop size now.
- X11RandR13 now disables the CRTC before XRRSetCrtcConfig(..)
to avoid invalid configuration (see spec)!
RandR 1.3 General:
- Uses unique id named instead of unstable index
for modes and CRTC.
This allows proper identification even for 'swizzled' devices.
Diffstat (limited to 'src/newt/native/X11RandR11.c')
-rw-r--r-- | src/newt/native/X11RandR11.c | 89 |
1 files changed, 35 insertions, 54 deletions
diff --git a/src/newt/native/X11RandR11.c b/src/newt/native/X11RandR11.c index 38d61289b..8d2651d61 100644 --- a/src/newt/native/X11RandR11.c +++ b/src/newt/native/X11RandR11.c @@ -297,75 +297,56 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenM DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); - int xrot = NewtScreen_Degree2XRotation(env, rotation); - XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); - - XSync(dpy, False); + Rotation xrot = NewtScreen_Degree2XRotation(env, rotation); XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, xrot, (short)freq, CurrentTime); - XSync(dpy, False); - return JNI_TRUE; } /* * Class: jogamp_newt_driver_x11_RandR11 - * Method: setCurrentScreenModePollEnd0 - * Signature: (JIII)Z + * Method: sendRRScreenChangeNotify0 + * Signature: (JIJIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenModePollEnd0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_sendRRScreenChangeNotify0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong jevent, jint resMode_idx, jint freq, jint rotation) { - Display *dpy = (Display *) (intptr_t) display; - int randr_event_base, randr_error_base; - XEvent evt; - XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; - + Display * dpy = (Display *) (intptr_t) display; + XEvent *event = (XEvent*)(intptr_t)jevent; + XRRUpdateConfiguration(event); + DBG_PRINT("RandR11_sendRRScreenChangeNotify0: dpy %p, event %p\n", dpy, event); + if( -1 == resMode_idx || -1 == screen_idx ) { + // No validation requested + return JNI_FALSE; + } + // Validate numbers .. + XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) event; int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); } - XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); - - int done = 0; - int rot; - do { - if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { - return JNI_FALSE; // not done + jboolean done = JNI_FALSE; + if(0 < scn_event->rotation ) { // All valid values greater zero: 0, 90, 180, 270, .. + int rot = NewtScreen_XRotation2Degree(env, scn_event->rotation); + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(OK) %p (root %p) resIdx %d rot %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, rot, + scn_event->width, scn_event->height); + // done = scn_event->size_index == resMode_idx; // not reliable .. + if( rot == rotation && + scn_event->width == xrrs[resMode_idx].width && + scn_event->height == xrrs[resMode_idx].height ) { + done = JNI_TRUE; } - XNextEvent(dpy, &evt); - - switch (evt.type - randr_event_base) { - case RRScreenChangeNotify: - if(0 < scn_event->rotation ) { - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; - } else { - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, - scn_event->width, scn_event->height); - } - break; - default: - DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); - } - XRRUpdateConfiguration(&evt); - } while(!done); - - XSync(dpy, False); - - return done ? JNI_TRUE : JNI_FALSE; + } else { // invalid .. skip + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(SKIP) %p (root %p) resIdx %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, + scn_event->width, scn_event->height); + } + return done; } + |