void QOpenKODEWindow::setGeometry(const QRect &rect) { if (isFullScreen) { QList<QPlatformScreen *> screens = QApplicationPrivate::platformIntegration()->screens(); QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(0)); widget()->setGeometry(screen->geometry()); return; } bool needToDeleteContext = false; if (!isFullScreen) { const QRect geo = geometry(); if (geo.size() != rect.size()) { const KDint windowSize[2] = { rect.width(), rect.height() }; if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { qErrnoWarning(kdGetError(), "Could not set native window size"); //return; } else { needToDeleteContext = true; } } if (geo.topLeft() != rect.topLeft()) { const KDint windowPos[2] = { rect.x(), rect.y() }; if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { qErrnoWarning(kdGetError(), "Could not set native window position"); //return; } else { needToDeleteContext = true; } } } //need to recreate context if (needToDeleteContext) { delete m_platformGlContext; QList<QPlatformScreen *> screens = QApplicationPrivate::platformIntegration()->screens(); QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(0)); EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig, m_eglContextAttrs.data(),surface,m_eglApi); } }
JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_WindowDriver_setSize0 (JNIEnv *env, jobject obj, jlong window, jint width, jint height) { KDWindow *w = (KDWindow*) (intptr_t) window; KDint32 v[] = { width, height }; int res = kdSetWindowPropertyiv(w, KD_WINDOWPROPERTY_SIZE, v); DBG_PRINT( "[setSize] v=%dx%d, res=%d\n", width, height, res); (void)res; (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); }
QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) : QPlatformWindow(tlw), isFullScreen(false) { if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenVG) { m_eglApi = EGL_OPENVG_API; } else { m_eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); m_eglContextAttrs.append(2); m_eglApi = EGL_OPENGL_ES_API; } eglBindAPI(m_eglApi); m_eglContextAttrs.append(EGL_NONE); m_eglWindowAttrs.append(EGL_NONE); QList<QPlatformScreen *> screens = QApplicationPrivate::platformIntegration()->screens(); //XXXX: jl figure out how to pick the correct screen. // Q_ASSERT(screens.size() > tlw->d_func()->screenNumber); // QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(tlw->d_func()->screenNumber)); QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(0)); if (!screen) { qErrnoWarning("Could not make QOpenKODEWindow without a screen"); } QPlatformWindowFormat format = tlw->platformWindowFormat(); format.setRedBufferSize(5); format.setGreenBufferSize(6); format.setBlueBufferSize(5); m_eglConfig = q_configFromQPlatformWindowFormat(screen->eglDisplay(),format); m_kdWindow = kdCreateWindow(screen->eglDisplay(), m_eglConfig, this); kdInstallCallback(kdProcessMouseEvents,KD_EVENT_INPUT_POINTER,this); #ifdef KD_ATX_keyboard kdInstallCallback(kdProcessKeyEvents, KD_EVENT_INPUT_KEY_ATX,this); #endif //KD_ATX_keyboard if (!m_kdWindow) { qErrnoWarning(kdGetError(), "Error creating native window"); return; } KDboolean exclusive(false); if (kdSetWindowPropertybv(m_kdWindow,KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, &exclusive)) { isFullScreen = true; } if (isFullScreen) { tlw->setGeometry(screen->geometry()); screen->setFullScreen(isFullScreen); }else { const KDint windowSize[2] = { tlw->width(), tlw->height() }; if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) { qErrnoWarning(kdGetError(), "Could not set native window size"); } KDboolean visibillity(false); if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) { qErrnoWarning(kdGetError(), "Could not set visibillity to false"); } const KDint windowPos[2] = { tlw->x(), tlw->y() }; if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) { qErrnoWarning(kdGetError(), "Could not set native window position"); return; } } QOpenKODEIntegration *integration = static_cast<QOpenKODEIntegration *>(QApplicationPrivate::platformIntegration()); if (!isFullScreen || (isFullScreen && !integration->mainGLContext())) { if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) { qErrnoWarning(kdGetError(), "Could not realize native window"); return; } EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(), m_eglConfig, m_eglContextAttrs.data(), surface, m_eglApi); integration->setMainGLContext(m_platformGLContext); } else { m_platformGlContext = integration->mainGLContext(); kdDestroyWindow(m_kdWindow); m_kdWindow = 0; } }