void QQnxWindow::setBufferSize(const QSize &size) { qWindowDebug() << Q_FUNC_INFO << "window =" << window() << "size =" << size; // Set window buffer size errno = 0; // libscreen fails when creating empty buffers const QSize nonEmptySize = size.isEmpty() ? QSize(1, 1) : size; int val[2] = { nonEmptySize.width(), nonEmptySize.height() }; int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val); if (result != 0) qFatal("QQnxWindow: failed to set window buffer size, errno=%d", errno); // Create window buffers if they do not exist if (m_bufferSize.isEmpty()) { val[0] = m_screen->nativeFormat(); #if !defined(QT_NO_OPENGL) // Get pixel format from EGL config if using OpenGL; // otherwise inherit pixel format of window's screen if (m_platformOpenGLContext != 0) val[0] = platformWindowFormatToNativeFormat(m_platformOpenGLContext->format()); #endif errno = 0; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val); if (result != 0) qFatal("QQnxWindow: failed to set window pixel format, errno=%d", errno); errno = 0; result = screen_create_window_buffers(m_window, MAX_BUFFER_COUNT); if (result != 0) qWarning() << "QQnxWindow: Buffer size was" << size; qFatal("QQnxWindow: failed to create window buffers, errno=%d", errno); // check if there are any buffers available int bufferCount = 0; result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount); if (result != 0) qFatal("QQnxWindow: failed to query window buffer count, errno=%d", errno); if (bufferCount != MAX_BUFFER_COUNT) { qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d. You might experience problems.", MAX_BUFFER_COUNT, bufferCount); } } // Cache new buffer size m_bufferSize = nonEmptySize; // Buffers were destroyed; reacquire them m_currentBufferIndex = -1; m_previousDirty = QRegion(); m_scrolled = QRegion(); const QMutexLocker locker(&m_mutex); m_requestedBufferSize = QSize(); }
void QQnxWindow::setGeometryHelper(const QRect &rect) { qWindowDebug() << Q_FUNC_INFO << "window =" << window() << ", (" << rect.x() << "," << rect.y() << "," << rect.width() << "," << rect.height() << ")"; // Call base class method QPlatformWindow::setGeometry(rect); // Set window geometry equal to widget geometry int val[2]; val[0] = rect.x(); val[1] = rect.y(); Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, val), "Failed to set window position"); val[0] = rect.width(); val[1] = rect.height(); Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val), "Failed to set window size"); // Set viewport size equal to window size Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val), "Failed to set window source size"); screen_flush_context(m_screenContext, 0); QWindowSystemInterface::handleGeometryChange(window(), rect); }
QRect QQnxWindow::setGeometryHelper(const QRect &rect) { qWindowDebug() << Q_FUNC_INFO << "window =" << window() << ", (" << rect.x() << "," << rect.y() << "," << rect.width() << "," << rect.height() << ")"; // Call base class method QRect oldGeometry = QPlatformWindow::geometry(); QPlatformWindow::setGeometry(rect); // Set window geometry equal to widget geometry errno = 0; int val[2]; val[0] = rect.x(); val[1] = rect.y(); int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, val); if (result != 0) qFatal("QQnxWindow: failed to set window position, errno=%d", errno); errno = 0; val[0] = rect.width(); val[1] = rect.height(); result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val); if (result != 0) qFatal("QQnxWindow: failed to set window size, errno=%d", errno); // Set viewport size equal to window size errno = 0; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val); if (result != 0) qFatal("QQnxWindow: failed to set window source size, errno=%d", errno); return oldGeometry; }
static void bb10display_createWindow(BB10Display *d) { screen_window_t window; if (d->window_created) { ms_warning("[bb10_display] window is already created, skipping..."); return; } screen_create_window_type(&window, d->context, SCREEN_CHILD_WINDOW); int usage = SCREEN_USAGE_NATIVE; screen_set_window_property_iv(window, SCREEN_PROPERTY_USAGE, &usage); int wdims[2] = { d->wsize.width, d->wsize.height }; screen_set_window_property_iv(window, SCREEN_PROPERTY_BUFFER_SIZE, wdims); screen_set_window_property_iv(window, SCREEN_PROPERTY_SOURCE_SIZE, wdims); int zorder = -5; screen_set_window_property_iv(window, SCREEN_PROPERTY_ZORDER, &zorder); screen_create_window_buffers(window, 1); ms_debug("[bb10_display] bb10display_createWindow window created with size %i,%i", wdims[0], wdims[1]); if (!d->pixmap_created) { bb10display_createPixmap(d); } d->window = window; d->window_created = TRUE; if (d->window_id != NULL && d->window_group != NULL) { bb10display_set_window_id_and_group(d); } }
ButtonMap::ButtonMap(screen_context_t screen_ctx, QString groupId, int coid) { this->screen_cxt = screen_ctx; this->groupId = groupId; this->coid = coid; const int usage = SCREEN_USAGE_NATIVE | SCREEN_USAGE_WRITE | SCREEN_USAGE_READ; int rc; if(screen_create_window_type(&screen_win, screen_cxt, SCREEN_CHILD_WINDOW)) { RARCH_ERR("ButtonMap: screen_create_window_type failed.\n"); } screen_join_window_group(screen_win, (const char *)groupId.toAscii().constData()); int format = SCREEN_FORMAT_RGBA8888; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format); screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage); screen_display_t screen_disp; if (screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp)) { RARCH_ERR("screen_get_window_property_pv [SCREEN_PROPERTY_DISPLAY] failed.\n"); } if (screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution)) { RARCH_ERR("screen_get_window_property_iv [SCREEN_PROPERTY_SIZE] failed.\n"); } rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, screen_resolution); if (rc) { perror("screen_set_window_property_iv"); } int z = -10; if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &z) != 0) { return; } rc = screen_create_window_buffers(screen_win, 1); if (rc) { perror("screen_create_window_buffers"); } screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); int bg[] = { SCREEN_BLIT_COLOR, 0x00000000, SCREEN_BLIT_GLOBAL_ALPHA, 0x80, SCREEN_BLIT_END }; screen_fill(screen_cxt, screen_buf, bg); screen_post_window(screen_win, screen_buf, 1, screen_resolution, 0); buttonDataModel = new ArrayDataModel(); refreshButtonMap(0); }
void BlackberryMain::startDisplays() { int num_configs; EGLint attrib_list[]= { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE}; const EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; screen_get_context_property_iv(screen_cxt, SCREEN_PROPERTY_DISPLAY_COUNT, &ndisplays); egl_disp = (EGLDisplay*)calloc(ndisplays, sizeof(EGLDisplay)); egl_surf = (EGLSurface*)calloc(ndisplays, sizeof(EGLSurface)); displays = (dispdata_t*)calloc(ndisplays, sizeof(dispdata_t)); screen_win = (screen_window_t *)calloc(ndisplays, sizeof(screen_window_t )); screen_dpy = (screen_display_t*)calloc(ndisplays, sizeof(screen_display_t)); screen_get_context_property_pv(screen_cxt, SCREEN_PROPERTY_DISPLAYS, (void **)screen_dpy); // Common data int usage = SCREEN_USAGE_ROTATION | SCREEN_USAGE_OPENGL_ES2; int format = SCREEN_FORMAT_RGBX8888; int sensitivity = SCREEN_SENSITIVITY_ALWAYS; // Initialise every display for (int i = 0; i < ndisplays; i++) { screen_get_display_property_iv(screen_dpy[i], SCREEN_PROPERTY_TYPE, &(displays[i].type)); screen_get_display_property_iv(screen_dpy[i], SCREEN_PROPERTY_ATTACHED, &(displays[i].attached)); screen_create_window(&screen_win[i], screen_cxt); screen_set_window_property_iv(screen_win[i], SCREEN_PROPERTY_FORMAT, &format); screen_set_window_property_iv(screen_win[i], SCREEN_PROPERTY_USAGE, &usage); screen_set_window_property_iv(screen_win[i], SCREEN_PROPERTY_SENSITIVITY, &sensitivity); screen_set_window_property_pv(screen_win[i], SCREEN_PROPERTY_DISPLAY, (void **)&screen_dpy[i]); egl_disp[i] = eglGetDisplay((EGLNativeDisplayType)i); eglInitialize(egl_disp[i], NULL, NULL); if (egl_cont == EGL_NO_CONTEXT) { eglChooseConfig(egl_disp[0], attrib_list, &egl_conf, 1, &num_configs); egl_cont = eglCreateContext(egl_disp[0], egl_conf, EGL_NO_CONTEXT, attributes); } fprintf(stderr, "Display %i: %s, %s\n", i, displayTypeString(displays[i].type), displays[i].attached ? "Attached" : "Detached"); if (displays[i].attached) realiseDisplay(i); } #ifdef ARM screen_get_display_property_iv(screen_dpy[0], SCREEN_PROPERTY_DPI, &dpi); // Only internal display has DPI // We only use dpi to calculate the width. Smaller aspect ratios have giant text despite high DPI. dpi = dpi * (((float)displays[0].width/(float)displays[0].height) / (16.0/9.0)); // Adjust to 16:9 #else dpi = 340.0f; #endif g_dpi_scale = 210.0f / dpi; switchDisplay(screen_ui); }
void BbVideoWindowControl::updateVideoPosition() { if (m_context && m_videoId != -1 && m_widget) { QPoint topLeft = m_fullscreen ? QPoint(0,0) : m_widget->mapToGlobal(m_displayRect.topLeft()); int width = m_fullscreen ? QApplication::desktop()->width() : m_displayRect.width(); int height = m_fullscreen ? QApplication::desktop()->height() : m_displayRect.height(); if (m_metaData.hasVideo()) { // We need the source size to do aspect ratio scaling const qreal sourceRatio = m_metaData.width() / static_cast<float>(m_metaData.height()); const qreal targetRatio = width / static_cast<float>(height); if (m_aspectRatioMode == Qt::KeepAspectRatio) { if (targetRatio < sourceRatio) { // Need to make height smaller const int newHeight = width / sourceRatio; const int heightDiff = height - newHeight; topLeft.ry() += heightDiff / 2; height = newHeight; } else { // Need to make width smaller const int newWidth = sourceRatio * height; const int widthDiff = width - newWidth; topLeft.rx() += widthDiff / 2; width = newWidth; } } else if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { if (targetRatio < sourceRatio) { // Need to make width larger const int newWidth = sourceRatio * height; const int widthDiff = newWidth - width; topLeft.rx() -= widthDiff / 2; width = newWidth; } else { // Need to make height larger const int newHeight = width / sourceRatio; const int heightDiff = newHeight - height; topLeft.ry() -= heightDiff / 2; height = newHeight; } } } if (m_window != 0) { const int position[2] = { topLeft.x(), topLeft.y() }; const int size[2] = { width, height }; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, position) != 0) perror("Setting video position failed"); if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, size) != 0) perror("Setting video size failed"); } } }
void MinutesPerGameRenderer::shutdown() { int pos[2] = { 0, 0 }; screen_set_window_property_iv(getWindow(), SCREEN_PROPERTY_POSITION, pos); int vis = 0; screen_set_window_property_iv(m_screen_win, SCREEN_PROPERTY_VISIBLE, &vis); }
int main(int argc, char **argv) { const int usage = SCREEN_USAGE_NATIVE; screen_window_t screen_win; screen_buffer_t screen_buf = NULL; int rect[4] = { 0, 0, 0, 0 }; // create an application window which will just act as a background screen_create_context(&screen_ctx, 0); screen_create_window(&screen_win, screen_ctx); screen_create_window_group(screen_win, vf_group); screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage); screen_create_window_buffers(screen_win, 1); screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); // fill the window with black int attribs[] = { SCREEN_BLIT_COLOR, 0x00000000, SCREEN_BLIT_END }; screen_fill(screen_ctx, screen_buf, attribs); screen_post_window(screen_win, screen_buf, 1, rect, 0); // position the window at an arbitrary z-order int i = APP_ZORDER; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &i); // Signal bps library that navigator and screen events will be requested bps_initialize(); screen_request_events(screen_ctx); navigator_request_events(0); // open camera and configure viewfinder if (init_camera() == EOK) { // our main loop just runs a state machine and handles input while (!shutdown) { run_state_machine(); // Handle user input handle_event(); } if (state == STATE_VIEWFINDER) { // clean up camera camera_stop_photo_viewfinder(handle); camera_close(handle); } } // Clean up screen_stop_events(screen_ctx); bps_shutdown(); screen_destroy_window(screen_win); screen_destroy_context(screen_ctx); return 0; }
static void handle_screen_event(bps_event_t *event) { int screen_val; screen_event_t screen_event = screen_event_get_event(event); screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); switch (screen_val) { case SCREEN_EVENT_MTOUCH_TOUCH: fprintf(stderr,"Touch event\n"); touch = true; break; case SCREEN_EVENT_MTOUCH_MOVE: fprintf(stderr,"Move event\n"); break; case SCREEN_EVENT_MTOUCH_RELEASE: fprintf(stderr,"Release event\n"); break; case SCREEN_EVENT_CREATE: // in a more involved application, it may be wise to actually check the window name to ensure // that we are processing the viewfinder window here, and not some other window if (screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_WINDOW, (void **)&vf_win) == -1) { perror("screen_get_event_property_pv(SCREEN_PROPERTY_WINDOW)"); } else { fprintf(stderr,"viewfinder window found!\n"); // mirror viewfinder if this is the front-facing camera int i = (shouldmirror?1:0); screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_MIRROR, &i); // place viewfinder in front of the black application background window. // note that a child window's ZORDER is relative to it's parent. // if we wanted to draw a UI on the application window, we could place the // viewfinder behind it and rely on transparency. or alternately, another // child window could be overlaid on top of the viewfinder. i = +1; screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_ZORDER, &i); // make viewfinder window visible i = 1; screen_set_window_property_iv(vf_win, SCREEN_PROPERTY_VISIBLE, &i); screen_flush_context(screen_ctx, 0); // we should now have a visible viewfinder // other things we could do here include rotating the viewfinder window (screen rotation), // or adjusting the size & position of the window. // some properties are immutable for security reasons since the window was actually created // in another process. anything related to presentation should be modifiable. touch = false; state = STATE_VIEWFINDER; } break; default: break; } }
int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { int rc; int nbuffers = fbconfig->doublebuffer ? 2 : 1; int format = SCREEN_FORMAT_RGBX8888; // TODO: check fbconfig int usage = SCREEN_USAGE_OPENGL_ES2|SCREEN_USAGE_OVERLAY; // TODO: check context config int size[2] = { wndconfig->width, wndconfig->height }; int pos[2] = { 0, 0 }; int interval = 1; if (!_glfwCreateContext(window, ctxconfig, fbconfig)) return GL_FALSE; rc = screen_create_window(&window->screen.window, _glfw.screen.context); if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Error creating window %s", strerror(errno)); return GL_FALSE; } if (wndconfig->monitor) { rc = screen_set_window_property_pv(window->screen.window, SCREEN_PROPERTY_DISPLAY, (void**)&wndconfig->monitor->screen.display); if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Error set window property %s", strerror(errno)); return GL_FALSE; } } rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_FORMAT, &format); if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set format property: %s", strerror(errno)); return GL_FALSE; } rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_USAGE, &usage); if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set usage property: %s", strerror(errno)); return GL_FALSE; } rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_SWAP_INTERVAL, &interval); if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set swap interval property: %s", strerror(errno)); return GL_FALSE; } rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_SIZE, size); if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set size property: %s", strerror(errno)); return GL_FALSE; } rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_POSITION, pos); if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set position property: %s", strerror(errno)); return GL_FALSE; } rc = screen_create_window_buffers(window->screen.window, nbuffers); if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to create window buffers: %s", strerror(errno)); return GL_FALSE; } return GL_TRUE; }
void QQnxRootWindow::resize(const QSize &size) { errno = 0; int val[] = {size.width(), size.height()}; int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val); if (result != 0) qFatal("QQnxRootWindow: failed to set window size, errno=%d", errno); errno = 0; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val); if (result != 0) qFatal("QQnxRootWindow: failed to set window source size, errno=%d", errno); // NOTE: display will update when child windows relayout and repaint }
// Take in JSON of value (bool) and handle (string) and return a message when complete std::string PreventSleepNDK::setPreventSleep(const std::string& inputString) { Json::Reader reader; Json::Value root; bool parse = reader.parse(inputString, root); if (!parse) { return "Cannot parse JSON object for Prevent Sleep"; } // the jsScreenWindowHandle of the UIWebView that we passed in int handle = static_cast<int>(strtol(root["handle"].asCString(), NULL, 10)); // As an integer is the actual window handle screen_window_t window = (screen_window_t) handle; // Set the mode to normal by default int mode = SCREEN_IDLE_MODE_NORMAL; if (root["value"].asBool()) { mode = SCREEN_IDLE_MODE_KEEP_AWAKE; } screen_set_window_property_iv(window, SCREEN_PROPERTY_IDLE_MODE, &mode); // check that we were successful, and we need to flush the command anyway screen_get_window_property_iv(window, SCREEN_PROPERTY_IDLE_MODE, &mode); if (mode == SCREEN_IDLE_MODE_KEEP_AWAKE) { preventSleepIsOn = true; return "Screen now keeping awake"; } else { preventSleepIsOn = false; return "Screen now allowed to sleep"; } }
int setup_screen() { /* * Create the window. */ if (screen_create_context(&screen_context, SCREEN_APPLICATION_CONTEXT) != 0) return EXIT_FAILURE; if (screen_create_window(&screen_window, screen_context) != 0) { screen_destroy_context(screen_context); return EXIT_FAILURE; } if (screen_create_window_group(screen_window, WINDOW_GROUP_NAME) != 0) return EXIT_FAILURE; int format = SCREEN_FORMAT_RGBA8888; if (screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_FORMAT, &format) != 0) return EXIT_FAILURE; int usage = SCREEN_USAGE_NATIVE; if (screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_USAGE, &usage) != 0) return EXIT_FAILURE; if (screen_create_window_buffers(screen_window, 1) != 0) return EXIT_FAILURE; // Get the render buffer screen_buffer_t temp_buffer[1]; if (screen_get_window_property_pv( screen_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)temp_buffer) != 0) return EXIT_FAILURE; // Fill the buffer with a solid color (green) int fill_attributes[3] = {SCREEN_BLIT_COLOR, 0x00C000, SCREEN_BLIT_END}; if (screen_fill(screen_context, temp_buffer[0], fill_attributes) != 0) return EXIT_FAILURE; // Make the window visible if (screen_get_window_property_iv(screen_window, SCREEN_PROPERTY_SIZE, screen_size) != 0) return EXIT_FAILURE; int temp_rectangle[4] = {0,0,screen_size[0],screen_size[1]}; if (screen_post_window(screen_window, temp_buffer[0], 1, temp_rectangle, 0) != 0) return EXIT_FAILURE; return EXIT_SUCCESS; }
void QQnxRootWindow::setRotation(int rotation) { qRootWindowDebug() << Q_FUNC_INFO << "angle =" << rotation; errno = 0; int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ROTATION, &rotation); if (result != 0) qFatal("QQnxRootWindow: failed to set window rotation, errno=%d", errno); }
void BbVideoWindowControl::updateSaturation() { if (m_window != 0) { const int backendValue = m_saturation * 1.27f; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SATURATION, &backendValue) != 0) perror("Setting saturation failed"); } }
void BbVideoWindowControl::updateHue() { if (m_window != 0) { const int backendValue = m_hue * 1.27f; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_HUE, &backendValue) != 0) perror("Setting hue failed"); } }
void BbVideoWindowControl::updateContrast() { if (m_window != 0) { const int backendValue = m_contrast * 1.27f; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_CONTRAST, &backendValue) != 0) perror("Setting contrast failed"); } }
void BbVideoWindowControl::updateBrightness() { if (m_window != 0) { const int backendValue = m_brightness * 2.55f; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BRIGHTNESS, &backendValue) != 0) perror("Setting brightness failed"); } }
bool_e qnxscreen_position(struct qnxscreen_api *q, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { int size[2] = {(int)w, (int)h}; int pos[2] = {(int)x, (int)y}; int ret; ret = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_POSITION, pos); if (ret) return false_e; ret = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_SIZE, size); if (ret) return false_e; return true_e; }
screen_window_t create_bar_window(const char *group, const char *id, int dims[2]) { screen_window_t screen_win; screen_create_window_type(&screen_win, screen_ctx, SCREEN_CHILD_WINDOW); screen_join_window_group(screen_win, group); screen_set_window_property_cv(screen_win, SCREEN_PROPERTY_ID_STRING, strlen(id), id); int vis = 1; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &vis); int zorder = 1; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &zorder); int color = 0xff0000ff; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_COLOR, &color); int rect[4] = { 0, 0, 1, 1 }; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); int pos[2] = { -rect[2], -rect[3] }; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_POSITION, pos); pos[0] = pos[1] = 0; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_POSITION, pos); int size[2] = {barwidth,dims[1]}; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, size); screen_buffer_t screen_buf; screen_create_window_buffers(screen_win, 1); screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); screen_post_window(screen_win, screen_buf, 1, rect, 0); return screen_win; }
screen_window_t create_bg_window(const char *group, int dims[2]) { /* Start by creating the application window and window group. */ screen_window_t screen_win; screen_create_window(&screen_win, screen_ctx); screen_create_window_group(screen_win, group); int vis = 1; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &vis); int color = 0xffffff00; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_COLOR, &color); int zorder = 0; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &zorder); int rect[4] = { 0, 0, 1, 1 }; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_SIZE, dims); screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, dims); int pos[2] = { -dims[0], -dims[1] }; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_POSITION, pos); screen_buffer_t screen_buf; screen_create_window_buffers(screen_win, 1); screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); screen_post_window(screen_win, screen_buf, 1, rect, 0); return screen_win; }
void QQnxRootWindow::makeTranslucent() { if (m_translucent) return; int result; errno = 0; result = screen_destroy_window_buffers(m_window); if (result != 0) { qFatal("QQnxRootWindow: failed to destroy window buffer, errno=%d", errno); } QRect geometry = m_screen->geometry(); errno = 0; int val[2]; val[0] = geometry.width(); val[1] = geometry.height(); result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val); if (result != 0) { qFatal("QQnxRootWindow: failed to set window buffer size, errno=%d", errno); } errno = 0; result = screen_create_window_buffers(m_window, 1); if (result != 0) { qFatal("QQNX: failed to create window buffer, errno=%d", errno); } // Install an alpha channel on the root window. // // This is necessary in order to avoid interfering with any particular // toplevel widget's QQnxWindow window instance from showing transparent // if it desires. errno = 0; val[0] = SCREEN_TRANSPARENCY_SOURCE_OVER; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val); if (result != 0) { qFatal("QQnxRootWindow: failed to set window transparency, errno=%d", errno); } m_translucent = true; post(); }
screen_window_t create_hg_window(const char *group, const char *id, int dims[2]) { int i, j; screen_window_t screen_win; screen_create_window_type(&screen_win, screen_ctx, SCREEN_CHILD_WINDOW); screen_join_window_group(screen_win, group); screen_set_window_property_cv(screen_win, SCREEN_PROPERTY_ID_STRING, strlen(id), id); int flag = 1; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_STATIC, &flag); int vis = 1; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &vis); int zorder = 2; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &zorder); int format = SCREEN_FORMAT_RGBA8888; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format); int usage = SCREEN_USAGE_WRITE; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage); int transparency = SCREEN_TRANSPARENCY_SOURCE_OVER; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_TRANSPARENCY, &transparency); int rect[4] = { 0, 0, 100, 100 }; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, &rect[2]); screen_buffer_t screen_buf; screen_create_window_buffers(screen_win, 1); screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); char *ptr = NULL; screen_get_buffer_property_pv(screen_buf, SCREEN_PROPERTY_POINTER, (void **)&ptr); int stride = 0; screen_get_buffer_property_iv(screen_buf, SCREEN_PROPERTY_STRIDE, &stride); for (i = 0; i < rect[3]; i++, ptr += stride) { for (j = 0; j < rect[2]; j++) { ptr[j*4] = 0xa0; ptr[j*4+1] = 0xa0; ptr[j*4+2] = 0xa0; ptr[j*4+3] = ((j >= i && j <= rect[3]-i) || (j <= i && j >= rect[3]-i)) ? 0xff : 0; } } screen_post_window(screen_win, screen_buf, 1, rect, 0); return screen_win; }
bool_e qnxscreen_rotate(struct qnxscreen_api *q, int32_t angle) { int ret; ret = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_ROTATION, (int *)&angle); if (ret) return false_e; return true_e; }
void QQnxWindow::setOpacity(qreal level) { qWindowDebug() << Q_FUNC_INFO << "window =" << window() << "opacity =" << level; // Set window global alpha int val = (int)(level * 255); Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_GLOBAL_ALPHA, &val), "Failed to set global alpha"); screen_flush_context(m_screenContext, 0); }
void QQnxWindow::updateVisibility(bool parentVisible) { qWindowDebug() << Q_FUNC_INFO << "parentVisible =" << parentVisible << "window =" << window(); // Set window visibility int val = (m_visible && parentVisible) ? 1 : 0; Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &val), "Failed to set window visibility"); Q_FOREACH (QQnxWindow *childWindow, m_childWindows) childWindow->updateVisibility(m_visible && parentVisible); }
int OpenGLView::setWindowUsage(int usage) { int returnCode = 0; if (m_screen_win != NULL) { returnCode = screen_set_window_property_iv(m_screen_win, SCREEN_PROPERTY_USAGE, &usage); } else { returnCode = EXIT_SUCCESS; } return returnCode; }
int OpenGLView::setWindowTransparency(int transparency) { int returnCode = 0; if (m_screen_win != NULL) { returnCode = screen_set_window_property_iv(m_screen_win, SCREEN_PROPERTY_TRANSPARENCY, &transparency); } else { returnCode = EXIT_SUCCESS; } return returnCode; }
int OpenGLView::setWindowZ(int z) { int returnCode = 0; if (m_screen_win != NULL) { returnCode = screen_set_window_property_iv(m_screen_win, SCREEN_PROPERTY_ZORDER, &z); } else { returnCode = EXIT_SUCCESS; } return returnCode; }