Window::Window(Type type, const uint32_t bufWidth, const uint32_t bufHeight, bool hasAlpha) : m_type(type) , m_appDesc(0) , m_removed(false) , m_disableKeepAlive(false) , m_bufWidth(bufWidth) , m_bufHeight(bufHeight) , m_initialWidth(bufWidth) , m_initialHeight(bufHeight) { setVisibleDimensions(bufWidth, bufHeight); if (type != Type_QtNativePaintWindow) { //launcher windows have no backing store. They're purely natively drawn m_screenPixmap = QPixmap(m_bufWidth, m_bufHeight); #if defined(TARGET_DESKTOP) && defined(HAVE_OPENGL) hasAlpha = false; #endif QColor fillColor(255, 255, 255, hasAlpha ? 0 : 255); m_screenPixmap.fill(fillColor); } WindowServer::registerWindow(this); }
CardHostWindow::CardHostWindow(WindowType::Type type, HostWindowData* data, IpcClientHost* clientHost) : CardWindow(type, data, clientHost) , m_paused(false) , m_pausedDueToDisplayOff(false) , m_penDownInPlayButton(false) , m_penInPlayButton(false) , m_inRotateAnim(false) , m_rotateAngleStart(0) , m_rotateAngleTarget(0) , m_rotateScaleStart(1.0f) , m_rotateScaleTarget(1.0f) , m_rotateTimerStart(0) , m_rotateAnimTimer(HostBase::instance()->masterTimer(), this, &CardHostWindow::rotateTimerTicked) { static QPixmap playButtonPixmap; static QPixmap scrimPixmap; m_prepareAddedToWm = true; // host windows don't get prepared m_touchEventsEnabled = true; setAcceptTouchEvents(true); setAcceptHoverEvents(true); int animationStrength = AS(cardTransitionCurve); m_rotateEquation = AS_EASEOUT(animationStrength); // FIXME: This should be an API m_winProps.setSuppressGestures(true); if (G_UNLIKELY(s_playButtonPixmap == 0)) { std::string filePath = Settings::LunaSettings()->lunaSystemResourcesPath + "/fullscreen-play-button.png"; playButtonPixmap = QPixmap(filePath.c_str()); s_playButtonPixmap = &playButtonPixmap; if (s_playButtonPixmap->isNull()) { g_critical("Failed to load image file: %s", filePath.c_str()); } } if (G_UNLIKELY(s_scrimPixmap == 0)) { std::string filePath = Settings::LunaSettings()->lunaSystemResourcesPath + "/scrim.png"; scrimPixmap = QPixmap(filePath.c_str()); s_scrimPixmap = &scrimPixmap; if (s_scrimPixmap->isNull()) { g_critical("Failed to load image file: %s", filePath.c_str()); } } //Also call onSetAppFixedOrientation() to initialize the rotation locking //It doesn't matter what the arguments are since we don't really use them. onSetAppFixedOrientation(Event::Orientation_Up, false); setVisibleDimensions(data->width(), data->height()); }
Window::Window(Type type, const QPixmap& pix) : m_type(type) , m_appDesc(0) , m_removed(false) , m_disableKeepAlive(false) , m_screenPixmap(pix) , m_bufWidth(pix.width()) , m_bufHeight(pix.height()) , m_initialWidth(pix.width()) , m_initialHeight(pix.height()) { setVisibleDimensions(m_bufWidth, m_bufHeight); WindowServer::registerWindow(this); }
void Window::resize(int w, int h) { m_bufWidth = w; m_bufHeight = h; setVisibleDimensions(w, h); // preserve alpha bool hasAlpha = m_screenPixmap.hasAlpha(); if (m_type != Type_QtNativePaintWindow) { m_screenPixmap = QPixmap(w, h); QColor fillColor(255, 255, 255, hasAlpha ? 0 : 255); m_screenPixmap.fill(fillColor); } // g_debug("%s: Window resized to %d x %d", __PRETTY_FUNCTION__, // m_bufWidth, m_bufHeight); }
void EmulatedCardWindow::resizeWindowBufferEvent(int w, int h, QRect windowScreenBounds, bool forceSync, bool ignoreFixedOrient) { bool directRendering = m_maximized; bool visible = isVisible() && this->sceneBoundingRect().intersects(WindowServer::instance()->sceneRect()); bool obscured = SystemUiController::instance()->maximizedCardWindow() ? (SystemUiController::instance()->maximizedCardWindow() != this) : false; bool synch = forceSync || m_maximized || (visible && !obscured); if((w == (int)m_bufWidth) && (h == (int)m_bufHeight)) { // already the right size, so do nothing return; } if(Settings::LunaSettings()->displayUiRotates) { if(directRendering) setMaximized(false); // disable direct rendering for the resize event //Emulated cards cannot resize to full screen, ever. int maxWidth = Settings::LunaSettings()->emulatedCardWidth; int maxHeight = Settings::LunaSettings()->emulatedCardHeight; m_screenMidLine = (SystemUiController::instance()->currentUiHeight() - Settings::LunaSettings()->positiveSpaceTopPadding)/2; if (!m_fullScreenMode) { maxHeight = maxHeight - Settings::LunaSettings()->positiveSpaceTopPadding; } w = (w > maxWidth ? maxWidth : w); h = (h > maxHeight ? maxHeight : h); if (w>h) { //Going to a landscape card setNewEmuRect(maxHeight, maxWidth); HostWindow::resizeEventSync(maxHeight,maxWidth); } else { //Going to a portrait card setNewEmuRect(maxWidth, maxHeight); HostWindow::resizeEventSync(maxWidth,maxHeight); } setBoundingRect(windowScreenBounds.width(), windowScreenBounds.height()); setVisibleDimensions(windowScreenBounds.width(), windowScreenBounds.height()); m_paintPath = QPainterPath(); m_paintPath.addRoundedRect(m_boundingRect, 25, 25); // reconstruct shadow CardDropShadowEffect* shadow = static_cast<CardDropShadowEffect*>(graphicsEffect()); if (shadow) { bool enable = shadow->isEnabled(); setGraphicsEffect(0); shadow = new CardDropShadowEffect(this); setGraphicsEffect(shadow); shadow->setEnabled(enable); } if(directRendering) setMaximized(true); // re-enable direct rendering } }