void QCursor::setPos(int x, int y) { //clip to screen size (window server allows a sprite hotspot to be outside the screen) if (x < 0) x=0; else if (x >= S60->screenWidthInPixels) x = S60->screenWidthInPixels - 1; if (y < 0) y = 0; else if (y >= S60->screenHeightInPixels) y = S60->screenHeightInPixels - 1; #ifndef QT_NO_CURSOR #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS if (S60->brokenPointerCursors && cursorSpriteVisible) cursorSprite.d->scurs.SetPosition(TPoint(x,y)); else #endif S60->wsSession().SetPointerCursorPosition(TPoint(x, y)); #endif S60->lastCursorPos = QPoint(x, y); //send a fake mouse move event, so that enter/leave events go to the widget hierarchy QWidget *w = QApplication::topLevelAt(S60->lastCursorPos); if (w) { CCoeControl* ctrl = w->effectiveWinId(); TPoint epos(x, y); TPoint cpos = epos - ctrl->PositionRelativeToScreen(); TPointerEvent fakeEvent; fakeEvent.iType = TPointerEvent::EMove; fakeEvent.iModifiers = 0U; fakeEvent.iPosition = cpos; fakeEvent.iParentPosition = epos; ctrl->HandlePointerEventL(fakeEvent); } }
bool QGraphicsVideoItemPrivate::eventFilter(QObject *object, QEvent *event) { if (windowControl && object == videoWidget && QEvent::WinIdChange == event->type()) { windowControl->setWinId(videoWidget->effectiveWinId()); } else { bool updateEventFiltersRequired = false; bool refreshDisplayRequired = false; foreach (QPointer<QObject> target, eventFilterTargets) { if (object == target.data()) { switch (event->type()) { case QEvent::ParentChange: updateEventFiltersRequired = true; refreshDisplayRequired = true; break; case QEvent::Move: case QEvent::Resize: refreshDisplayRequired = true; break; } } } if (updateEventFiltersRequired) updateEventFilters(); #ifdef Q_OS_SYMBIAN if (refreshDisplayRequired && windowControl) QMetaObject::invokeMethod(windowControl, "refreshDisplay"); #endif } return false; }
WId QWidgetProto::effectiveWinId() const { QWidget *item = qscriptvalue_cast<QWidget*>(thisObject()); if (item) return item->effectiveWinId(); return WId(); }
/*! Enables / disables the Swipe of the Harmattan. This is used on sorting mode when the user can drag item over the edge of the UI. */ void QtHelper::enableSwipe(bool enable) { #ifdef Q_WS_HARMATTAN QWidget *activeWindow = QApplication::activeWindow(); Display *dpy = QX11Info::display(); Atom atom; if (!activeWindow) { return; } atom = XInternAtom(dpy, "_MEEGOTOUCH_CUSTOM_REGION", False); if (enable) { XDeleteProperty(dpy, activeWindow->effectiveWinId(), atom); } else { unsigned int customRegion[] = { activeWindow->x(), activeWindow->y(), activeWindow->width(), activeWindow->height() }; XChangeProperty(dpy, activeWindow->winId(), atom, XA_CARDINAL, 32, PropModeReplace, reinterpret_cast<unsigned char*>(&customRegion[0]), 4); } #endif }
void IndicatorsManager::checkMousePosition() { // Called by m_mouseTrackerTimer to implement mouse scrubbing // (Assuming item A menu is opened, move mouse over item B => item B menu opens) // Also, delivers motion events to Qt, which will generate correct // enter/leave events for IndicatorEntry widgets. QPoint pos = QCursor::pos(); // Don't send the event unless the mouse has moved // https://bugs.launchpad.net/bugs/834065 if (!m_lastMousePosition.isNull() && (m_lastMousePosition == pos)) { return; } m_lastMousePosition = pos; QWidget* widget = QApplication::widgetAt(pos); Display* display = QX11Info::display(); QPoint relPos = widget != 0 ? widget->mapFromGlobal(pos) : pos; XMotionEvent event = { MotionNotify, 0, False, display, widget != 0 ? widget->effectiveWinId() : 0, widget != 0 ? RootWindow(display, widget->x11Info().screen()) : 0, 0, CurrentTime, pos.x(), pos.y(), relPos.x(), relPos.y(), 0, False, True }; qApp->x11ProcessEvent(reinterpret_cast<XEvent*>(&event)); IndicatorEntryWidget* entryWidget = qobject_cast<IndicatorEntryWidget*>(widget); if (!entryWidget) { return; } entryWidget->showMenu(Qt::NoButton); }
/*! Constructs the CVideoPlayerUtility2 object with given \a service and \a object. And Registers for Video Loading Notifications. */ S60VideoPlayerSession::S60VideoPlayerSession(QMediaService *service, S60MediaNetworkAccessControl *object) : S60MediaPlayerSession(service) , m_accessPointId(0) , m_wsSession(&CCoeEnv::Static()->WsSession()) , m_screenDevice(CCoeEnv::Static()->ScreenDevice()) , m_service(service) , m_player(0) #ifndef VIDEOOUTPUT_GRAPHICS_SURFACES , m_dsaActive(false) , m_dsaStopped(false) #endif , m_videoOutputControl(0) , m_videoOutputDisplay(0) , m_displayWindow(0) #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER , m_audioOutput(0) #endif , m_audioEndpoint(DefaultAudioEndpoint) , m_pendingChanges(0) , m_backendInitiatedPause(false) { DP0("S60VideoPlayerSession::S60VideoPlayerSession +++"); m_networkAccessControl = object; #ifdef VIDEOOUTPUT_GRAPHICS_SURFACES QT_TRAP_THROWING(m_player = CVideoPlayerUtility2::NewL( *this, 0, EMdaPriorityPreferenceNone )); m_player->RegisterForVideoLoadingNotification(*this); #else RWindow *window = 0; QRect extentRect; QWidget *widget = QApplication::activeWindow(); if (!widget) widget = QApplication::allWidgets().at(0); Q_ASSERT(widget); WId wid = widget->effectiveWinId(); if (!wid) wid = widget->winId(); window = static_cast<RWindow *>(wid->DrawableWindow()); extentRect = QRect(widget->mapToGlobal(widget->pos()), widget->size()); TRect clipRect = QRect2TRect(extentRect); const TRect desktopRect = QRect2TRect(QApplication::desktop()->screenGeometry()); clipRect.Intersection(desktopRect); QT_TRAP_THROWING(m_player = CVideoPlayerUtility::NewL( *this, 0, EMdaPriorityPreferenceNone, *m_wsSession, *m_screenDevice, *window, QRect2TRect(extentRect), clipRect)); m_dsaActive = true; m_player->RegisterForVideoLoadingNotification(*this); #endif // VIDEOOUTPUT_GRAPHICS_SURFACES S60VideoPlayerEventHandler::instance()->addApplicationFocusObserver(this); DP0("S60VideoPlayerSession::S60VideoPlayerSession ---"); }
/*! Traverse QObject based items. */ void TasQtTraverse::traverseObject(TasObject* objectInfo, QObject* object, TasCommand* command) { // Embedded apps must use coordinates for operations, as the parent has no knowledge of the // Actual items bool embeddedApp = false; if (command && command->parameter("embedded") == "true") { embeddedApp = true; } //TasLogger::logger()->debug("TasQtTraverse::traverseObject in"); mTraverseUtils->addObjectDetails(objectInfo, object); QGraphicsObject* graphicsObject = qobject_cast<QGraphicsObject*>(object); if(graphicsObject){ objectInfo->addAttribute("objectType", embeddedApp? TYPE_WEB : TYPE_GRAPHICS_VIEW); mTraverseUtils->addGraphicsItemCoordinates(objectInfo, graphicsObject, command); mTraverseUtils->printGraphicsItemProperties(objectInfo, graphicsObject); //add details only for graphicsitems QGraphicsWidget* graphicsWidget = qobject_cast<QGraphicsWidget*>(object); if(graphicsWidget){ mTraverseUtils->addFont(objectInfo, graphicsWidget->font()); // Elided format "this is a text" -> "this is a..." text for // items that have the "text" property. QVariant text = graphicsWidget->property("text"); if (text.isValid()) { mTraverseUtils->addTextInfo(objectInfo, text.toString(), graphicsWidget->font(), graphicsWidget->size().width()); } QVariant plainText = graphicsWidget->property("plainText"); if (plainText.isValid()) { mTraverseUtils->addTextInfo(objectInfo, plainText.toString(), graphicsWidget->font(), graphicsWidget->size().width()); } } } else{ QQuickItem* quickObject = qobject_cast<QQuickItem*>(object); if (quickObject) { objectInfo->addAttribute("objectType", TYPE_QSCENEGRAPH ); } //make sure that we are dealing with a widget else if (object->isWidgetType()){ QWidget* widget = qobject_cast<QWidget*>(object); objectInfo->addAttribute("objectType", TYPE_STANDARD_VIEW ); addWidgetCoordinates(objectInfo, widget,command); mTraverseUtils->addFont(objectInfo, widget->font()); //check is the widget a viewport to graphicsscene QWidget* parentWidget = widget->parentWidget(); bool isViewPort = false; if(parentWidget && parentWidget->inherits("QGraphicsView")){ QGraphicsView* view = qobject_cast<QGraphicsView*>(parentWidget); if(view->viewport() == widget){ isViewPort = true; } } //add transformation details QGraphicsView* graphicsView = qobject_cast<QGraphicsView*>(object); if(graphicsView){ objectInfo->addBooleanAttribute("isTransformed", graphicsView->isTransformed()); if(graphicsView->isTransformed()){ QTransform tr = graphicsView->transform(); objectInfo->addAttribute("transformM11",tr.m11()); objectInfo->addAttribute("transformM12",tr.m12()); objectInfo->addAttribute("transformM13",tr.m13()); objectInfo->addAttribute("transformM21",tr.m21()); objectInfo->addAttribute("transformM22",tr.m22()); objectInfo->addAttribute("transformM23",tr.m23()); objectInfo->addAttribute("transformM31",tr.m31()); objectInfo->addAttribute("transformM32",tr.m32()); objectInfo->addAttribute("transformM33",tr.m33()); } } objectInfo->addBooleanAttribute("isViewPort", isViewPort); // Add special window id attribute into qwidget atttributes #if defined(Q_WS_X11) unsigned long wid = static_cast<unsigned long>(widget->effectiveWinId()); objectInfo->addAttribute("xWindow", (int)wid); // can this fail due to precision? #endif } else if(object->isWindowType()) { objectInfo->addAttribute("objectType", TYPE_WINDOW_VIEW); } else { if(object != qApp){ objectInfo->addAttribute("objectType", embeddedApp? TYPE_WEB : TYPE_STANDARD_VIEW ); } } } }